
Create xml:base attribute with LINQ to XML
May 25, 2008Attribute xml:base belongs to namespace http://www.w3.org/XML/1998/namespace. In LINQ to XML this namespace you can get from class property XNamespace.XML. XNamespace.Xml returns namespace http://www.w3.org/XML/1998/namespace.
You can create xml:base atribute in this way:
XElement myEl = new XElement(“Root”,
new XAttribute(XNamespace.XML+”base”, “attributeValue”)
);
The result is:
<Root xml:base=”attributeValue”/>


