Прочетете на английски Редактиране

Споделяне чрез


XmlTextReader Constructors

Definition

Initializes a new instance of the XmlTextReader.

Overloads

XmlTextReader()

Initializes a new instance of the XmlTextReader.

XmlTextReader(String, XmlNodeType, XmlParserContext)

Initializes a new instance of the XmlTextReader class with the specified string, XmlNodeType, and XmlParserContext.

XmlTextReader(String, TextReader, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified URL, TextReader and XmlNameTable.

XmlTextReader(String, Stream, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified URL, stream and XmlNameTable.

XmlTextReader(Stream, XmlNodeType, XmlParserContext)

Initializes a new instance of the XmlTextReader class with the specified stream, XmlNodeType, and XmlParserContext.

XmlTextReader(String, TextReader)

Initializes a new instance of the XmlTextReader class with the specified URL and TextReader.

XmlTextReader(String, Stream)

Initializes a new instance of the XmlTextReader class with the specified URL and stream.

XmlTextReader(String, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified file and XmlNameTable.

XmlTextReader(Stream, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified stream and XmlNameTable.

XmlTextReader(XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified XmlNameTable.

XmlTextReader(String)

Initializes a new instance of the XmlTextReader class with the specified file.

XmlTextReader(TextReader)

Initializes a new instance of the XmlTextReader class with the specified TextReader.

XmlTextReader(Stream)

Initializes a new instance of the XmlTextReader class with the specified stream.

XmlTextReader(TextReader, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified TextReader and XmlNameTable.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

XmlTextReader()

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader.

C#
protected XmlTextReader();

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(String, XmlNodeType, XmlParserContext)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified string, XmlNodeType, and XmlParserContext.

C#
public XmlTextReader(string xmlFragment, System.Xml.XmlNodeType fragType, System.Xml.XmlParserContext? context);
C#
public XmlTextReader(string xmlFragment, System.Xml.XmlNodeType fragType, System.Xml.XmlParserContext context);

Parameters

xmlFragment
String

The string containing the XML fragment to parse.

fragType
XmlNodeType

The XmlNodeType of the XML fragment. This also determines what the fragment string can contain. (See table below.)

context
XmlParserContext

The XmlParserContext in which the xmlFragment is to be parsed. This includes the XmlNameTable to use, encoding, namespace scope, the current xml:lang, and the xml:space scope.

Exceptions

fragType is not an Element, Attribute, or DocumentXmlNodeType.

xmlFragment is null.

Examples

The following example parses an XML fragment. It uses the XmlParserContext and its XmlNamespaceManager to handle namespace resolution.

C#
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> " +
                    "<title>Pride And Prejudice</title>" +
                    "<bk:genre>novel</bk:genre>" +
                    "</book>";

    //Create the XmlNamespaceManager.
    NameTable nt = new NameTable();
    XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
    nsmgr.AddNamespace("bk", "urn:sample");

    //Create the XmlParserContext.
    XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

    //Create the reader.
    XmlTextReader reader = new XmlTextReader(xmlFrag, XmlNodeType.Element, context);

    //Parse the XML.  If they exist, display the prefix and
    //namespace URI of each element.
    while (reader.Read()){
      if (reader.IsStartElement()){
        if (reader.Prefix==String.Empty)
                {
                    Console.WriteLine("<{0}>", reader.LocalName);
                }
                else
                {
            Console.Write("<{0}:{1}>", reader.Prefix, reader.LocalName);
            Console.WriteLine(" The namespace URI is " + reader.NamespaceURI);
        }
      }
    }

    //Close the reader.
    reader.Close();
  }
} // End class

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

This constructor parses the given string as a fragment of XML. If the XML fragment is an element or attribute, you can bypass the root level rules for well-formed XML documents. This constructor can handle strings returned from ReadInnerXml.

The following table lists valid values for fragType and how the reader parses each of the different node types.

XmlNodeType Fragment May Contain
Element Any valid element content (for example, any combination of elements, comments, processing instructions, CDATA sections, text, and entity references).

An XML declaration can also be supplied. This allows you to specify the encoding for the XML fragment, rather than having to set it on the XmlParserContext object.
Attribute The value of an attribute (the part inside the quotes).
Document The contents of an entire XML document. This enforces document level rules.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(String, TextReader, XmlNameTable)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified URL, TextReader and XmlNameTable.

C#
public XmlTextReader(string url, System.IO.TextReader input, System.Xml.XmlNameTable nt);

Parameters

url
String

The URL to use for resolving external resources. The BaseURI is set to this value. If url is null, BaseURI is set to String.Empty.

input
TextReader

The TextReader containing the XML data to read.

nt
XmlNameTable

The XmlNameTable to use.

Exceptions

The nt value is null.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

It is assumed that the TextReader is already set to the correct encoding. This is used by clients that have already read some things from the stream in a multi-part MIME scenario.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(String, Stream, XmlNameTable)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified URL, stream and XmlNameTable.

C#
public XmlTextReader(string url, System.IO.Stream input, System.Xml.XmlNameTable nt);

Parameters

url
String

The URL to use for resolving external resources. The BaseURI is set to this value. If url is null, BaseURI is set to String.Empty.

input
Stream

The stream containing the XML data to read.

nt
XmlNameTable

The XmlNameTable to use.

Exceptions

The input or nt value is null.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(Stream, XmlNodeType, XmlParserContext)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified stream, XmlNodeType, and XmlParserContext.

C#
public XmlTextReader(System.IO.Stream xmlFragment, System.Xml.XmlNodeType fragType, System.Xml.XmlParserContext? context);
C#
public XmlTextReader(System.IO.Stream xmlFragment, System.Xml.XmlNodeType fragType, System.Xml.XmlParserContext context);

Parameters

xmlFragment
Stream

The stream containing the XML fragment to parse.

fragType
XmlNodeType

The XmlNodeType of the XML fragment. This also determines what the fragment can contain. (See table below.)

context
XmlParserContext

The XmlParserContext in which the xmlFragment is to be parsed. This includes the XmlNameTable to use, encoding, namespace scope, the current xml:lang, and the xml:space scope.

Exceptions

fragType is not an Element, Attribute, or Document XmlNodeType.

xmlFragment is null.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

This constructor parses the given string as a fragment of XML. If the XML fragment is an element or attribute, you can bypass the root level rules for well-formed XML documents.

The following table lists valid values for fragType.

XmlNodeType Fragment May Contain
Element Any valid element content (for example, any combination of elements, comments, processing instructions, CDATA sections, text, and entity references).

An XML declaration can also be supplied. This allows you to specify the encoding for the XML fragment, rather than having to set it on the XmlParserContext object.
Attribute The value of an attribute (the part inside the quotes).
Document The contents of an entire XML document. This enforces document level rules.

The reader uses the following to determine the encoding of the stream.

  1. Checks the XmlParserContext.Encoding property to determine the encoding.

  2. If the Encoding property is null, the reader checks for a byte-order mark at the beginning of the stream.

  3. If the Encoding property is null, and no byte-order mark is found, the reader assumes the stream is encoded in UTF-8.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(String, TextReader)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified URL and TextReader.

C#
public XmlTextReader(string url, System.IO.TextReader input);

Parameters

url
String

The URL to use for resolving external resources. The BaseURI is set to this value.

input
TextReader

The TextReader containing the XML data to read.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

It is assumed that the TextReader is already set to the correct encoding. This is used by clients that have already read some things from the stream in a multi-part MIME scenario.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(String, Stream)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified URL and stream.

C#
public XmlTextReader(string url, System.IO.Stream input);

Parameters

url
String

The URL to use for resolving external resources. The BaseURI is set to this value.

input
Stream

The stream containing the XML data to read.

Exceptions

input is null.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(String, XmlNameTable)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified file and XmlNameTable.

C#
public XmlTextReader(string url, System.Xml.XmlNameTable nt);

Parameters

url
String

The URL for the file containing the XML data to read.

nt
XmlNameTable

The XmlNameTable to use.

Exceptions

The nt value is null.

The specified file cannot be found.

Part of the filename or directory cannot be found.

url is an empty string.

The remote filename cannot be resolved.

-or-

An error occurred while processing the request.

url is not a valid URI.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(Stream, XmlNameTable)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified stream and XmlNameTable.

C#
public XmlTextReader(System.IO.Stream input, System.Xml.XmlNameTable nt);

Parameters

input
Stream

The stream containing the XML data to read.

nt
XmlNameTable

The XmlNameTable to use.

Exceptions

The input or nt value is null.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

The XmlTextReader decodes the stream using System.Text.Encoding.

If you specify a name table, this constructor uses the names defined already in that table.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(XmlNameTable)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified XmlNameTable.

C#
protected XmlTextReader(System.Xml.XmlNameTable nt);

Parameters

nt
XmlNameTable

The XmlNameTable to use.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(String)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified file.

C#
public XmlTextReader(string url);

Parameters

url
String

The URL for the file containing the XML data. The BaseURI is set to this value.

Exceptions

The specified file cannot be found.

Part of the filename or directory cannot be found.

url is an empty string.

The remote filename cannot be resolved.

-or-

An error occurred while processing the request.

url is not a valid URI.

Examples

The following example reads an XML file and displays each of the nodes.

C#
using System;
using System.IO;
using System.Xml;

public class Sample {

  private const String filename = "items.xml";

  public static void Main() {

     XmlTextReader reader = null;

     try {

        // Load the reader with the data file and ignore all white space nodes.
        reader = new XmlTextReader(filename);
        reader.WhitespaceHandling = WhitespaceHandling.None;

        // Parse the file and display each of the nodes.
        while (reader.Read()) {
           switch (reader.NodeType) {
             case XmlNodeType.Element:
               Console.Write("<{0}>", reader.Name);
               break;
             case XmlNodeType.Text:
               Console.Write(reader.Value);
               break;
             case XmlNodeType.CDATA:
               Console.Write("<![CDATA[{0}]]>", reader.Value);
               break;
             case XmlNodeType.ProcessingInstruction:
               Console.Write("<?{0} {1}?>", reader.Name, reader.Value);
               break;
             case XmlNodeType.Comment:
               Console.Write("<!--{0}-->", reader.Value);
               break;
             case XmlNodeType.XmlDeclaration:
               Console.Write("<?xml version='1.0'?>");
               break;
             case XmlNodeType.Document:
               break;
             case XmlNodeType.DocumentType:
               Console.Write("<!DOCTYPE {0} [{1}]", reader.Name, reader.Value);
               break;
             case XmlNodeType.EntityReference:
               Console.Write(reader.Name);
               break;
             case XmlNodeType.EndElement:
               Console.Write("</{0}>", reader.Name);
               break;
           }
        }
     }

     finally {
        if (reader!=null)
          reader.Close();
     }
  }
} // End class

The example uses the file, items.xml, as input.

XML

<?xml version="1.0"?>
<!-- This is a sample XML document -->
<!DOCTYPE Items [<!ENTITY number "123">]>
<Items>
  <Item>Test with an entity: &number;</Item>
  <Item>test with a child element <more/> stuff</Item>
  <Item>test with a CDATA section <![CDATA[<456>]]> def</Item>
  <Item>Test with an char entity: A</Item>
  <!-- Fourteen chars in this element.-->
  <Item>1234567890ABCD</Item>
</Items>

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

If the file is located on a resource that requires access credentials, use the XmlResolver property to specify the necessary credentials.

Бележка

In version 1.1 of the .NET Framework, partially trusted code cannot set the XmlResolver property. The workaround is to create an XmlUrlResolver with the necessary credentials, pass the URI to the XmlUrlResolver.GetEntity method, and then construct the XmlTextReader using the resulting Stream object. The workaround is described in the following C# code.

C#
// Create a resolver with the necessary credentials.
XmlUrlResolver resolver = new XmlUrlResolver();
NetworkCredential nc = new NetworkCredential(SecurelyStoredUserName, SecurelyStoredPassword, SecurelyStoredDomain);
resolver.Credentials = nc;
// Get a Stream object containing the XML file.
Uri myUri = new Uri ("http://myServer/data/books.xml");
Stream s=(Stream)resolver.GetEntity(myUri, null, typeof(Stream));
// Construct a reader using the Stream object.
XmlTextReader reader = new XmlTextReader(s);

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(TextReader)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified TextReader.

C#
public XmlTextReader(System.IO.TextReader input);

Parameters

input
TextReader

The TextReader containing the XML data to read.

Examples

The following example loads an XML string into the XmlTextReader object using the StringReader class.

C#
using System;
using System.IO;
using System.Xml;

public class Sample {

  public static void Main() {

    string xmlData =
    @"<book>
       <title>Oberon's Legacy</title>
       <price>5.95</price>
      </book>";

    // Create the reader.
    XmlTextReader reader = new XmlTextReader(new StringReader(xmlData));
    reader.WhitespaceHandling = WhitespaceHandling.None;

    // Display each element node.
    while (reader.Read()){
       switch (reader.NodeType){
         case XmlNodeType.Element:
           Console.Write("<{0}>", reader.Name);
           break;
         case XmlNodeType.Text:
           Console.Write(reader.Value);
           break;
         case XmlNodeType.EndElement:
           Console.Write("</{0}>", reader.Name);
           break;
      }
    }

    // Close the reader.
    reader.Close();
  }
} // End class

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

It is assumed that the TextReader is already set to the correct encoding. This is used by clients that have already read some things from the stream in a multi-part MIME scenario.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(Stream)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified stream.

C#
public XmlTextReader(System.IO.Stream input);

Parameters

input
Stream

The stream containing the XML data to read.

Exceptions

input is null.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

The XmlTextReader decodes the stream using System.Text.Encoding.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

XmlTextReader(TextReader, XmlNameTable)

Source:
XmlTextReader.cs
Source:
XmlTextReader.cs
Source:
XmlTextReader.cs

Initializes a new instance of the XmlTextReader class with the specified TextReader and XmlNameTable.

C#
public XmlTextReader(System.IO.TextReader input, System.Xml.XmlNameTable nt);

Parameters

input
TextReader

The TextReader containing the XML data to read.

nt
XmlNameTable

The XmlNameTable to use.

Exceptions

The nt value is null.

Remarks

Бележка

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

It is assumed that the TextReader is already set to the correct encoding. This is used by clients that have already read some things from the stream in a multi-part MIME scenario.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1