How can i remove preprocessing instructions from an XML in a greener way? suppose that I have this xml in a string
variable (which is a property of a class),I wante
If you can load it in an XmlDocument: FirstChild returns the node, and
NextSibling
returns the rest.
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNode node = doc.FirstChild.NextSibling;
Edit: Your xml looks a lot like the example on msdn for XPathNavigator.Select. Have you tried using that?
Edit2: You can get the name of the top level element using:
string topLevelNode = doc.DocumentElement.Name;