ReadEndElement Method
TOC
Collapse the table of content
Expand the table of content

XmlReader.ReadEndElement Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Checks that the current content node is an end tag and advances the reader to the next node.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public virtual void ReadEndElement()

ExceptionCondition
XmlException

The current node is not an end tag or if incorrect XML is encountered in the input stream.



StringBuilder output = new StringBuilder();

String xmlString =
    @"<book>
    <title>Pride And Prejudice</title>
    <price>19.95</price>
</book>";

using (XmlReader reader = XmlReader.Create(new StringReader(xmlString)))
{
    // Parse the XML document. 
    reader.Read();
    reader.ReadStartElement("book");
    reader.ReadStartElement("title");
    output.AppendLine("The content of the title element:  ");
    output.AppendLine(reader.ReadContentAsString());
    reader.ReadEndElement();
    reader.ReadStartElement("price");
    output.AppendLine("The content of the price element:  ");
    output.AppendLine(reader.ReadContentAsDouble().ToString());
    reader.ReadEndElement();
    reader.ReadEndElement();

}

OutputTextBlock.Text = output.ToString();


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft