10/30/11

Invalid Expanded Name LINQ to XML

In the System.Xml.Linq API, the concatenation of the namespace and a local element name creates the expanded name. When an invalid expanded name exception is raised, it can occur when a LINQ to XML query uses an element attribute, and the attribute name that is used is an empty string. For example, with an Xml like this: <Items><item id=”1”>one</item><item id=”2”>two</item> <item>three...

10/28/11

How to Clone XDocument

The XDocument class does not implement the ICloneable interface, so there is no Clone method to call. There is however a constructor that allow us to do this. The constructor takes an instance of XDocument and creates a new instance with the same XML structure. This can be done with the following code: string xmlString = "<items><item/><item/></items>"; .. TextReader...