XmlReader.ReadStartElement Method (String)
[ 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 element with the given Name and advances the reader to the next node.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- name
- Type: System.String
The qualified name of the element.
| Exception | Condition |
|---|---|
| XmlException | IsStartElement returns false or if the Name of the element does not match the given name. |
A call to this method corresponds to a call to IsStartElement followed by a call to Read.
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();
Show: