static void ReadXml() { string a= null; double b= 0; double c= 0; XmlReader xmlReader = new XmlReader("Testxml.xml"); xmlReader. using (xmlReader) { if (xmlReader != null) { while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { switch (xmlReader.Name) { case "a": a = xmlReader.ReadElementContentAsString(); break; case "b": b = double.Parse(xmlReader.ReadElementContentAsString()); break; case "c": c = double.Parse(xmlReader.ReadElementContentAsString()); break; } } } } } }
TestXML Content:
<a><b>26a83f12c782</b><c>128</c><d>12</d></a>
Case b never hits. But if I add a space after the end element b, then case b will fall. Now, how to make it work without changing the xml file?
c #
Learningner
source share