I am trying to read a certain section from an xml file in C#. I tried using this code here but I get a compiler error under the Text
in XmlNodeType.Text
but the weird thing is it comes up with intellisense and gives the same error with everything else like Element
,Comment
etc.. what am I missing?
XmlTextReader reader = new XmlTextReader(xmlDoc);
List<string> paths = new List<string>();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "Paths")
foreach(XmlNodeType.Text aa in reader.ReadInnerXml())
paths.Add(aa);
}
reader.Close();
XML file
<Config>
<Paths>
<Input>C:\</Input>
<Output>C:\</Output>
<Log>\Logs</Log>
</Paths>
<SystemOwnerRoles>
<Supplier>SUPPLIER</Supplier>
<Mop>MOP</Mop>
</SystemOwnerRoles>
</Config>