XMLReader in silverlight <test /> type tag problem

Posted by Ummar on Stack Overflow See other posts from Stack Overflow or by Ummar
Published on 2010-04-30T07:42:35Z Indexed on 2010/04/30 7:47 UTC
Read the original article Hit count: 406

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.

© Stack Overflow or respective owner

Related posts about xmlreader

Related posts about c#