XML Literals

Mercury has full support for Visual Basic.NET's XML Literals, with a few additions.

In Microsoft Visual Basic.NET, XML Literals map to types from the Linq to XML class library, such as XElement, XCData and the like. These classes ar eof course speciifc to the .NET platform.

In Mercury, XML Literals instead map to types from the native XML Document implementation in our cross-platform Elements RTL library, such as XmlElement. This allows XML Literals to be used on all platforms, and with a consistent (albeit different) API on the resulting objects.

Mercury supports falling back to using XElement & Co for backward compatibility with existing code, when compiling for .NET and .NET Core. This can be achived in two ways:

  1. Assigning an XML Literal to a strongly typed variable, of a Linq to XML type will force the XML literal to use that mode, e.g. "Dim x As XElement = <xml />."
  2. Setting the "XML Literals (Mercury)" Project Setting from "Elements RTL" (the default) to "Linq to XML" will force all XML Literals to default to using XElement (unless assigned to a strongly typed XmlElement of course).