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.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; int main() { // Create the XML fragment to be parsed. String^ xmlFrag = "<book>\n" "<misc>\n" "<style>paperback</style>\n" "<pages>240</pages>\n" "</misc>\n" "</book>\n"; // Create the XmlNamespaceManager. XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( gcnew NameTable ); // Create the XmlParserContext. XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::None ); // Create the reader. XmlValidatingReader^ reader = gcnew XmlValidatingReader( xmlFrag,XmlNodeType::Element,context ); IXmlLineInfo^ lineInfo = (dynamic_cast<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:

