XmlParserContext Constructeurs

Définition

Initialise une nouvelle instance de la XmlParserContext classe avec les valeurs spécifiées.

Surcharges

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

Initialise une nouvelle instance de la XmlParserContext classe avec les valeurs, et XmlNameTableXmlNamespaceManagerxml:lang les valeurs spécifiées.xml:space

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

Initialise une nouvelle instance de la XmlParserContext classe avec le codage , , XmlNameTableXmlNamespaceManagerxml:langet le codage spécifiés.xml:space

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

Initialise une nouvelle instance de la XmlParserContext classe avec les valeurs de type de document, URI de base, XmlNameTableXmlNamespaceManageret d’URI de base spécifiésxml:langxml:space.

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

Initialise une nouvelle instance de la XmlParserContext classe avec les valeurs de type de document spécifiées XmlNameTable, XmlNamespaceManagerURI de base, xml:lang, xml:spaceencodage et type de document.

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace)

Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs

Initialise une nouvelle instance de la XmlParserContext classe avec les valeurs, et XmlNameTableXmlNamespaceManagerxml:lang les valeurs spécifiées.xml:space

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)

Paramètres

nt
XmlNameTable

À XmlNameTable utiliser pour atomiser les chaînes. Si c’est nullle cas, la table de noms utilisée pour construire l’objet est utilisée à la nsMgr place. Pour plus d’informations sur les chaînes atomisées, consultez XmlNameTable.

nsMgr
XmlNamespaceManager

À XmlNamespaceManager utiliser pour rechercher des informations d’espace de noms, ou null.

xmlLang
String

Étendue xml:lang .

xmlSpace
XmlSpace

Valeur XmlSpace indiquant l’étendue xml:space .

Exceptions

nt n’est pas le même XmlNameTable utilisé pour construire nsMgr.

Exemples

L’exemple suivant lit un fragment XML. Il utilise un XmlParserContext et son XmlNamespaceManager pour gérer la correspondance d’espace de noms.

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

S’applique à

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

Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs

Initialise une nouvelle instance de la XmlParserContext classe avec le codage , , XmlNameTableXmlNamespaceManagerxml:langet le codage spécifiés.xml:space

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)

Paramètres

nt
XmlNameTable

À XmlNameTable utiliser pour atomiser les chaînes. Si c’est nullle cas, la table de noms utilisée pour construire l’objet est utilisée à la nsMgr place. Pour plus d’informations sur les chaînes atomisées, consultez XmlNameTable.

nsMgr
XmlNamespaceManager

À XmlNamespaceManager utiliser pour rechercher des informations d’espace de noms, ou null.

xmlLang
String

Étendue xml:lang .

xmlSpace
XmlSpace

Valeur XmlSpace indiquant l’étendue xml:space .

enc
Encoding

Objet Encoding indiquant le paramètre d’encodage.

Exceptions

nt n’est pas le même XmlNameTable utilisé pour construire nsMgr.

S’applique à

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

Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs

Initialise une nouvelle instance de la XmlParserContext classe avec les valeurs de type de document, URI de base, XmlNameTableXmlNamespaceManageret d’URI de base spécifiésxml:langxml:space.

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)

Paramètres

nt
XmlNameTable

À XmlNameTable utiliser pour atomiser les chaînes. Si c’est nullle cas, la table de noms utilisée pour construire l’objet est utilisée à la nsMgr place. Pour plus d’informations sur les chaînes atomisées, consultez XmlNameTable.

nsMgr
XmlNamespaceManager

À XmlNamespaceManager utiliser pour rechercher des informations d’espace de noms, ou null.

docTypeName
String

Nom de la déclaration de type de document.

pubId
String

Identificateur public.

sysId
String

Identificateur système.

internalSubset
String

Sous-ensemble DTD interne. Le sous-ensemble DTD est utilisé pour la résolution d’entités, et non pour la validation de document.

baseURI
String

URI de base pour le fragment XML (emplacement à partir duquel le fragment a été chargé).

xmlLang
String

Étendue xml:lang .

xmlSpace
XmlSpace

Valeur XmlSpace indiquant l’étendue xml:space .

Exceptions

nt n’est pas le même XmlNameTable utilisé pour construire nsMgr.

Exemples

L’exemple suivant utilise un XmlParserContext fragment XML pour lire un fragment 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

Remarques

Ce constructeur fournit toutes les DocumentType informations requises par XmlValidatingReader. S’il XmlParserContext est passé à un XmlTextReaderDTD, toutes les informations DTD sont ignorées.

Si vous passez un DTD en tant que DTD, le DTD est utilisé pour la internalSubsetrésolution d’entité, et non pour la validation de document.

S’applique à

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

Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs
Source:
XmlParserContext.cs

Initialise une nouvelle instance de la XmlParserContext classe avec les valeurs de type de document spécifiées XmlNameTable, XmlNamespaceManagerURI de base, xml:lang, xml:spaceencodage et type de document.

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)

Paramètres

nt
XmlNameTable

À XmlNameTable utiliser pour atomiser les chaînes. Si c’est nullle cas, la table de noms utilisée pour construire l’objet est utilisée à la nsMgr place. Pour plus d’informations sur les chaînes atomisées, consultez XmlNameTable.

nsMgr
XmlNamespaceManager

À XmlNamespaceManager utiliser pour rechercher des informations d’espace de noms, ou null.

docTypeName
String

Nom de la déclaration de type de document.

pubId
String

Identificateur public.

sysId
String

Identificateur système.

internalSubset
String

Sous-ensemble DTD interne. Le DTD est utilisé pour la résolution d’entité, et non pour la validation de document.

baseURI
String

URI de base pour le fragment XML (emplacement à partir duquel le fragment a été chargé).

xmlLang
String

Étendue xml:lang .

xmlSpace
XmlSpace

Valeur XmlSpace indiquant l’étendue xml:space .

enc
Encoding

Objet Encoding indiquant le paramètre d’encodage.

Exceptions

nt n’est pas le même XmlNameTable utilisé pour construire nsMgr.

S’applique à