XmlParserContext Konstruktory

Definice

Inicializuje novou instanci XmlParserContext třídy se zadanými hodnotami.

Přetížení

Name Description
XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace)

Inicializuje novou instanci XmlParserContext třídy se zadaným XmlNameTable, XmlNamespaceManager, xml:langa xml:space hodnoty.

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace, Encoding)

Inicializuje novou instanci XmlParserContext třídy se zadaným XmlNameTable, XmlNamespaceManager, xml:lang, xml:space, a kódování.

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace)

Inicializuje novou instanci XmlParserContext třídy se zadaným XmlNameTable, XmlNamespaceManager, základní identifikátor URI, xml:lang, xml:spacea hodnoty typu dokumentu.

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace, Encoding)

Inicializuje novou instanci XmlParserContext třídy se zadaným XmlNameTable, XmlNamespaceManager, základní identifikátor URI, xml:lang, , xml:spacekódování a hodnoty typu dokumentu.

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace)

Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs

Inicializuje novou instanci XmlParserContext třídy se zadaným XmlNameTable, XmlNamespaceManager, xml:langa xml:space hodnoty.

public:
 XmlParserContext(System::Xml::XmlNameTable ^ nt, System::Xml::XmlNamespaceManager ^ nsMgr, System::String ^ xmlLang, System::Xml::XmlSpace xmlSpace);
public XmlParserContext(System.Xml.XmlNameTable nt, System.Xml.XmlNamespaceManager nsMgr, string xmlLang, System.Xml.XmlSpace xmlSpace);
public XmlParserContext(System.Xml.XmlNameTable? nt, System.Xml.XmlNamespaceManager? nsMgr, string? xmlLang, System.Xml.XmlSpace xmlSpace);
new System.Xml.XmlParserContext : System.Xml.XmlNameTable * System.Xml.XmlNamespaceManager * string * System.Xml.XmlSpace -> System.Xml.XmlParserContext
Public Sub New (nt As XmlNameTable, nsMgr As XmlNamespaceManager, xmlLang As String, xmlSpace As XmlSpace)

Parametry

nt
XmlNameTable

Použití XmlNameTable k atomizaci řetězců. Pokud se nulljedná o tabulku názvů použitou k vytvoření, nsMgr použije se místo toho. Další informace o atomizovaných řetězcích naleznete v tématu XmlNameTable.

nsMgr
XmlNamespaceManager

Slouží XmlNamespaceManager k vyhledání informací o oboru názvů nebo null.

xmlLang
String

Obor xml:lang .

xmlSpace
XmlSpace

Hodnota XmlSpace označující xml:space obor.

Výjimky

nt není stejná XmlNameTable jako při vytváření nsMgr.

Příklady

Následující příklad načte fragment XML. Používá a XmlParserContext jeho XmlNamespaceManager zpracování porovnávání oborů názvů.

using System;
using System.IO;
using System.Xml;

public class Sample
{
    public static void Main()
    {
        XmlTextReader reader = null;

        try
        {
            //Create the XML fragment to be parsed.
            string xmlFrag = "<book> " +
                            "<title>Pride And Prejudice</title>" +
                            "<bk:genre>novel</bk:genre>" +
                            "</book>";

            //Create the XmlNamespaceManager that is used to
            //look up namespace information.
            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);

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

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

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

Public Class Sample

    Public Shared Sub Main()
        Dim reader As XmlTextReader = Nothing

        Try
            'Create the XML fragment to be parsed.
            Dim xmlFrag As String = "<book> " & _
                                    "<title>Pride And Prejudice</title>" & _
                                    "<bk:genre>novel</bk:genre>" & _
                                    "</book>"

            'Create the XmlNamespaceManager that is used to
            'look up namespace information.
            Dim nt As New NameTable()
            Dim nsmgr As New XmlNamespaceManager(nt)
            nsmgr.AddNamespace("bk", "urn:sample")

            'Create the XmlParserContext.
            Dim context As New XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)

            'Implement the reader. 
            reader = New XmlTextReader(xmlFrag, XmlNodeType.Element, context)

            'Parse the XML fragment.  If they exist, display the   
            'prefix and namespace URI of each element.
            While reader.Read()
                If reader.IsStartElement() Then
                    If reader.Prefix = String.Empty Then
                        Console.WriteLine("<{0}>", reader.LocalName)
                    Else
                        Console.Write("<{0}:{1}>", reader.Prefix, reader.LocalName)
                        Console.WriteLine(" The namespace URI is " & reader.NamespaceURI)
                    End If
                End If
            End While
        Finally
            If Not (reader Is Nothing) Then
                reader.Close()
            End If
        End Try
    End Sub
End Class

Platí pro

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace, Encoding)

Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs

Inicializuje novou instanci XmlParserContext třídy se zadaným XmlNameTable, XmlNamespaceManager, xml:lang, xml:space, a kódování.

public:
 XmlParserContext(System::Xml::XmlNameTable ^ nt, System::Xml::XmlNamespaceManager ^ nsMgr, System::String ^ xmlLang, System::Xml::XmlSpace xmlSpace, System::Text::Encoding ^ enc);
public XmlParserContext(System.Xml.XmlNameTable nt, System.Xml.XmlNamespaceManager nsMgr, string xmlLang, System.Xml.XmlSpace xmlSpace, System.Text.Encoding enc);
public XmlParserContext(System.Xml.XmlNameTable? nt, System.Xml.XmlNamespaceManager? nsMgr, string? xmlLang, System.Xml.XmlSpace xmlSpace, System.Text.Encoding? enc);
new System.Xml.XmlParserContext : System.Xml.XmlNameTable * System.Xml.XmlNamespaceManager * string * System.Xml.XmlSpace * System.Text.Encoding -> System.Xml.XmlParserContext
Public Sub New (nt As XmlNameTable, nsMgr As XmlNamespaceManager, xmlLang As String, xmlSpace As XmlSpace, enc As Encoding)

Parametry

nt
XmlNameTable

Použití XmlNameTable k atomizaci řetězců. Pokud se nulljedná o tabulku názvů použitou k vytvoření, nsMgr použije se místo toho. Další informace o atomizovaných řetězcích naleznete v tématu XmlNameTable.

nsMgr
XmlNamespaceManager

Slouží XmlNamespaceManager k vyhledání informací o oboru názvů nebo null.

xmlLang
String

Obor xml:lang .

xmlSpace
XmlSpace

Hodnota XmlSpace označující xml:space obor.

enc
Encoding

Objekt Encoding označující nastavení kódování.

Výjimky

nt není stejná XmlNameTable jako při vytváření nsMgr.

Platí pro

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace)

Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs

Inicializuje novou instanci XmlParserContext třídy se zadaným XmlNameTable, XmlNamespaceManager, základní identifikátor URI, xml:lang, xml:spacea hodnoty typu dokumentu.

public:
 XmlParserContext(System::Xml::XmlNameTable ^ nt, System::Xml::XmlNamespaceManager ^ nsMgr, System::String ^ docTypeName, System::String ^ pubId, System::String ^ sysId, System::String ^ internalSubset, System::String ^ baseURI, System::String ^ xmlLang, System::Xml::XmlSpace xmlSpace);
public XmlParserContext(System.Xml.XmlNameTable nt, System.Xml.XmlNamespaceManager nsMgr, string docTypeName, string pubId, string sysId, string internalSubset, string baseURI, string xmlLang, System.Xml.XmlSpace xmlSpace);
public XmlParserContext(System.Xml.XmlNameTable? nt, System.Xml.XmlNamespaceManager? nsMgr, string? docTypeName, string? pubId, string? sysId, string? internalSubset, string? baseURI, string? xmlLang, System.Xml.XmlSpace xmlSpace);
new System.Xml.XmlParserContext : System.Xml.XmlNameTable * System.Xml.XmlNamespaceManager * string * string * string * string * string * string * System.Xml.XmlSpace -> System.Xml.XmlParserContext
Public Sub New (nt As XmlNameTable, nsMgr As XmlNamespaceManager, docTypeName As String, pubId As String, sysId As String, internalSubset As String, baseURI As String, xmlLang As String, xmlSpace As XmlSpace)

Parametry

nt
XmlNameTable

Použití XmlNameTable k atomizaci řetězců. Pokud se nulljedná o tabulku názvů použitou k vytvoření, nsMgr použije se místo toho. Další informace o atomizovaných řetězcích naleznete v tématu XmlNameTable.

nsMgr
XmlNamespaceManager

Slouží XmlNamespaceManager k vyhledání informací o oboru názvů nebo null.

docTypeName
String

Název deklarace typu dokumentu.

pubId
String

Veřejný identifikátor.

sysId
String

Systémový identifikátor.

internalSubset
String

Interní podmnožina DTD. Podmnožina DTD se používá pro překlad entit, ne pro ověřování dokumentu.

baseURI
String

Základní identifikátor URI fragmentu XML (umístění, ze kterého byl fragment načten).

xmlLang
String

Obor xml:lang .

xmlSpace
XmlSpace

Hodnota XmlSpace označující xml:space obor.

Výjimky

nt není stejná XmlNameTable jako při vytváření nsMgr.

Příklady

Následující příklad používá XmlParserContext k načtení fragmentu XML.

using System;
using System.IO;
using System.Xml;

public class Sample
{
    public static void Main()
    {
        XmlTextReader reader = null;

        try
        {
            //Create the XML fragment to be parsed.
            string xmlFrag = "<book genre='novel' misc='sale-item &h;'></book>";

            //Create the XmlParserContext. The XmlParserContext provides the
            //necessary DTD information so that the entity reference can be expanded.
            XmlParserContext context;
            string subset = "<!ENTITY h 'hardcover'>";
            context = new XmlParserContext(null, null, "book", null, null, subset, "", "", XmlSpace.None);

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

            //Read the all the attributes on the book element.
            reader.MoveToContent();
            while (reader.MoveToNextAttribute())
            {
                Console.WriteLine("{0} = {1}", reader.Name, reader.Value);
            }
        }
        finally
        {
            if (reader != null)
                reader.Close();
        }
    }
} // End class
Option Explicit On
Option Strict On

Imports System.IO
Imports System.Xml

Public Class Sample

    Public Shared Sub Main()
        Dim reader As XmlTextReader = Nothing
        Try
            'Create the XML fragment to be parsed.
            Dim xmlFrag As String = "<book genre='novel' misc='sale-item &h;'></book>"

            'Create the XmlParserContext. The XmlParserContext provides the 
            'necessary DTD information so that the entity reference can be expanded.
            Dim context As XmlParserContext
            Dim subset As String = "<!ENTITY h 'hardcover'>"
            context = New XmlParserContext(Nothing, Nothing, "book", Nothing, Nothing, subset, "", "", XmlSpace.None)

            'Create the reader. 
            reader = New XmlTextReader(xmlFrag, XmlNodeType.Element, context)

            'Read the all the attributes on the book element.
            reader.MoveToContent()
            While reader.MoveToNextAttribute()
                Console.WriteLine("{0} = {1}", reader.Name, reader.Value)
            End While
        Finally
            If Not (reader Is Nothing) Then
                reader.Close()
            End If
        End Try
    End Sub
End Class

Poznámky

Tento konstruktor poskytuje všechny DocumentType informace vyžadované XmlValidatingReader. Pokud se tento XmlParserContext parametr předá XmlTextReader, všechny informace DTD se ignorují.

Pokud jako DTD předáte DTD internalSubset, použije se DTD pro překlad entit, ne pro ověření dokumentu.

Platí pro

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace, Encoding)

Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs
Zdroj:
XmlParserContext.cs

Inicializuje novou instanci XmlParserContext třídy se zadaným XmlNameTable, XmlNamespaceManager, základní identifikátor URI, xml:lang, , xml:spacekódování a hodnoty typu dokumentu.

public:
 XmlParserContext(System::Xml::XmlNameTable ^ nt, System::Xml::XmlNamespaceManager ^ nsMgr, System::String ^ docTypeName, System::String ^ pubId, System::String ^ sysId, System::String ^ internalSubset, System::String ^ baseURI, System::String ^ xmlLang, System::Xml::XmlSpace xmlSpace, System::Text::Encoding ^ enc);
public XmlParserContext(System.Xml.XmlNameTable nt, System.Xml.XmlNamespaceManager nsMgr, string docTypeName, string pubId, string sysId, string internalSubset, string baseURI, string xmlLang, System.Xml.XmlSpace xmlSpace, System.Text.Encoding enc);
public XmlParserContext(System.Xml.XmlNameTable? nt, System.Xml.XmlNamespaceManager? nsMgr, string? docTypeName, string? pubId, string? sysId, string? internalSubset, string? baseURI, string? xmlLang, System.Xml.XmlSpace xmlSpace, System.Text.Encoding? enc);
new System.Xml.XmlParserContext : System.Xml.XmlNameTable * System.Xml.XmlNamespaceManager * string * string * string * string * string * string * System.Xml.XmlSpace * System.Text.Encoding -> System.Xml.XmlParserContext
Public Sub New (nt As XmlNameTable, nsMgr As XmlNamespaceManager, docTypeName As String, pubId As String, sysId As String, internalSubset As String, baseURI As String, xmlLang As String, xmlSpace As XmlSpace, enc As Encoding)

Parametry

nt
XmlNameTable

Použití XmlNameTable k atomizaci řetězců. Pokud se nulljedná o tabulku názvů použitou k vytvoření, nsMgr použije se místo toho. Další informace o atomizovaných řetězcích naleznete v tématu XmlNameTable.

nsMgr
XmlNamespaceManager

Slouží XmlNamespaceManager k vyhledání informací o oboru názvů nebo null.

docTypeName
String

Název deklarace typu dokumentu.

pubId
String

Veřejný identifikátor.

sysId
String

Systémový identifikátor.

internalSubset
String

Interní podmnožina DTD. DTD se používá pro překlad entit, ne pro ověření dokumentu.

baseURI
String

Základní identifikátor URI fragmentu XML (umístění, ze kterého byl fragment načten).

xmlLang
String

Obor xml:lang .

xmlSpace
XmlSpace

Hodnota XmlSpace označující xml:space obor.

enc
Encoding

Objekt Encoding označující nastavení kódování.

Výjimky

nt není stejná XmlNameTable jako při vytváření nsMgr.

Platí pro