I'm sure all the pros out there would find this very trivial but I need a quick solution for this in C#
I'm retrieving an xml schema of a view in share point which looks like this:
<FieldRef Name="LinkTitle"/><FieldRef Name="Author0"/><FieldRef Name="ID"/>
I want to parse this and only retrieve the Name's of each root element in this schema. currently this is the code I'm working on , need some help with it
String fieldvals = view.ViewFields.SchemaXml.ToString();
XmlDocument reader = new XmlDocument(); ;
reader.LoadXml(fieldvals);
String xpath = "/";
var nodes = reader.SelectNodes(xpath);
foreach (XmlNode childrenNode in nodes)
{
Console.WriteLine(childrenNode.SelectSingleNode("//field1").Value);
}
Apparently, when this piece of code executes, I get an exception saying that more than one root node is present which is true of course .. but I'm not able to figure out the correct code to access every root node and extract it's name!