XmlReader.Create Method (TextReader)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Creates a new XmlReader instance with the specified TextReader.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- input
- Type: System.IO.TextReader
The TextReader from which to read the XML data. Because a TextReader returns a stream of Unicode characters, the encoding specified in the XML declaration is not used by the XmlReader to decode the data stream.
| Exception | Condition |
|---|---|
| NullReferenceException | The input value is null. |
An XmlReaderSettings object with default settings is used to create the reader. If you wish to specify the features to support on the created reader, use the overload that takes an XmlReaderSettings object as one of its arguments, and pass in an XmlReaderSettings object with the correct settings.
StringBuilder output = new StringBuilder(); String xmlString = @"<root> <stringValue> <!--comment--> <?some pi?> text value of the element. </stringValue> <longValue>270000000000001</longValue> <number>0</number> <double>2E10</double> <date>2003-01-08T15:00:00-00:00</date> </root>"; using (XmlReader reader = XmlReader.Create(new StringReader(xmlString))) { reader.ReadToFollowing("longValue"); long number = reader.ReadElementContentAsLong(); output.AppendLine(number.ToString()); } OutputTextBlock.Text = output.ToString();