XMLReader in silverlight <test /> type tag problem
- by Ummar
Hi I am parsing XML in silverlight, in my XML I have one tag is like
<test attribute1="123" />
<test1 attribute2="345">abc text</test1>
I am using XMLReader to parse xml like
using (XmlReader reader = XmlReader.Create(new StringReader(xmlString)))
{
// Parse the file and display each of the nodes.
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
//process start tag here
break;
case XmlNodeType.Text:
//process text here
break;
case XmlNodeType.XmlDeclaration:
case XmlNodeType.ProcessingInstruction:
break;
case XmlNodeType.Comment:
break;
case XmlNodeType.EndElement:
//process end tag here
break;
}
}
}
but the problem is that for test tag no EndElement is received? which is making my whole program logic wrong. (for test1 tag all works fine). Please help me out.