The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
IXmlLineInfo Interface
.NET Framework (current version)
Provides an interface to enable a class to return line and position information.
Assembly: System.Xml (in System.Xml.dll)
| Name | Description | |
|---|---|---|
![]() | LineNumber | Gets the current line number. |
![]() | LinePosition | Gets the current line position. |
| Name | Description | |
|---|---|---|
![]() | HasLineInfo() | Gets a value indicating whether the class can return line information. |
The following example parses an XML fragment. Each node is displayed, including its depth, line number, and line position.
using System; using System.IO; using System.Xml; public class Sample{ public static void Main(){ // Create the XML fragment to be parsed. string xmlFrag = @"<book> <misc> <style>paperback</style> <pages>240</pages> </misc> </book> "; // Create the XmlNamespaceManager. XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); // Create the XmlParserContext. XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); // Create the reader. XmlValidatingReader reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context); IXmlLineInfo lineInfo = ((IXmlLineInfo)reader); if (lineInfo.HasLineInfo()){ // Parse the XML and display each node. while (reader.Read()){ switch (reader.NodeType){ case XmlNodeType.Element: Console.Write("{0} {1},{2} ", reader.Depth, lineInfo.LineNumber, lineInfo.LinePosition); Console.WriteLine("<{0}>", reader.Name); break; case XmlNodeType.Text: Console.Write("{0} {1},{2} ", reader.Depth, lineInfo.LineNumber, lineInfo.LinePosition); Console.WriteLine(" {0}", reader.Value); break; case XmlNodeType.EndElement: Console.Write("{0} {1},{2} ", reader.Depth, lineInfo.LineNumber, lineInfo.LinePosition); Console.WriteLine("</{0}>", reader.Name); break; } } } // Close the reader. reader.Close(); } }
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show:

