<a><b>26a83f12c782</b><c>128</c><d>12</d></a>
static void ReadXml1()
{
string b = null;
double c = 0;
double d = 0;
using (XmlTextReader xmlReader = new XmlTextReader("Testxml.xml"))
{
if (xmlReader != null)
{
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element)
{
switch (xmlReader.Name)
{
case "b":
b = xmlReader.ReadElementContentAsString();
break;
case "c":
c = double.Parse(xmlReader.ReadElementContentAsString());
break;
case "d":
d = double.Parse(xmlReader.ReadElementContentAsString());
break;
}
}
}
}
}
}
The first line is in the Testxml.xml file. Case "c" is never hit. But if I add a space after </b>
in xml file, it will work. But I can't change the xml file. So how do I get the value of c element.