XmlParserContext Constructors
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Initialiseert een nieuw exemplaar van de XmlParserContext klasse met de opgegeven waarden.
Overloads
| Name | Description |
|---|---|
| XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace) |
Initialiseert een nieuw exemplaar van de |
| XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace, Encoding) |
Initialiseert een nieuw exemplaar van de |
| XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace) |
Initialiseert een nieuw exemplaar van de |
| XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace, Encoding) |
Initialiseert een nieuw exemplaar van de |
XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace)
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
Initialiseert een nieuw exemplaar van de XmlParserContext klasse met de opgegeven XmlNameTable, XmlNamespaceManageren xml:langxml:space waarden.
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)
Parameters
- nt
- XmlNameTable
Het XmlNameTable te gebruiken om tekenreeksen te atomiseren. Als dit het is null, wordt in plaats daarvan de naamtabel gebruikt die wordt gebruikt om de nsMgr tabel te maken. Zie voor meer informatie over atomiseerde tekenreeksen XmlNameTable.
- nsMgr
- XmlNamespaceManager
De XmlNamespaceManager te gebruiken functie voor het opzoeken van naamruimtegegevens of null.
- xmlLang
- String
Het xml:lang bereik.
Uitzonderingen
nt is niet hetzelfde XmlNameTable dat wordt gebruikt om te bouwen nsMgr.
Voorbeelden
In het volgende voorbeeld wordt een XML-fragment gelezen. Er wordt gebruikgemaakt van een XmlParserContext en de bijbehorende XmlNamespaceManager naamruimtekoppeling.
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
Van toepassing op
XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace, Encoding)
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
Initialiseert een nieuw exemplaar van de XmlParserContext klasse met de opgegeven XmlNameTable, XmlNamespaceManager, xml:lang, xml:spaceen codering.
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)
Parameters
- nt
- XmlNameTable
Het XmlNameTable te gebruiken om tekenreeksen te atomiseren. Als dit het is null, wordt in plaats daarvan de naamtabel gebruikt die wordt gebruikt om de nsMgr tabel te maken. Zie voor meer informatie over atomiseerde tekenreeksen XmlNameTable.
- nsMgr
- XmlNamespaceManager
De XmlNamespaceManager te gebruiken functie voor het opzoeken van naamruimtegegevens of null.
- xmlLang
- String
Het xml:lang bereik.
Uitzonderingen
nt is niet hetzelfde XmlNameTable dat wordt gebruikt om te bouwen nsMgr.
Van toepassing op
XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace)
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
Initialiseert een nieuw exemplaar van de XmlParserContext klasse met de opgegeven XmlNameTable, XmlNamespaceManagerbasis-URI en xml:langxml:spacedocumenttypewaarden.
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)
Parameters
- nt
- XmlNameTable
Het XmlNameTable te gebruiken om tekenreeksen te atomiseren. Als dit het is null, wordt in plaats daarvan de naamtabel gebruikt die wordt gebruikt om de nsMgr tabel te maken. Zie voor meer informatie over atomiseerde tekenreeksen XmlNameTable.
- nsMgr
- XmlNamespaceManager
De XmlNamespaceManager te gebruiken functie voor het opzoeken van naamruimtegegevens of null.
- docTypeName
- String
De naam van de declaratie van het documenttype.
- pubId
- String
De openbare id.
- sysId
- String
De systeem-id.
- internalSubset
- String
De interne DTD-subset. De DTD-subset wordt gebruikt voor entiteitsomzetting, niet voor documentvalidatie.
- baseURI
- String
De basis-URI voor het XML-fragment (de locatie van waaruit het fragment is geladen).
- xmlLang
- String
Het xml:lang bereik.
Uitzonderingen
nt is niet hetzelfde XmlNameTable dat wordt gebruikt om te bouwen nsMgr.
Voorbeelden
In het volgende voorbeeld wordt een XmlParserContext XML-fragment gelezen.
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
Opmerkingen
Deze constructor levert alle DocumentType informatie die vereist is voor XmlValidatingReader. Als dit XmlParserContext wordt doorgegeven aan een XmlTextReader, worden alle DTD-gegevens genegeerd.
Als u een DTD als de internalSubsetDTD doorgeeft, wordt de DTD gebruikt voor entiteitsomzetting, niet voor documentvalidatie.
Van toepassing op
XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace, Encoding)
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
- Bron:
- XmlParserContext.cs
Initialiseert een nieuw exemplaar van de XmlParserContext klasse met de opgegeven XmlNameTable, XmlNamespaceManagerbasis-URI, xml:lang, xml:spacecodering en documenttypewaarden.
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)
Parameters
- nt
- XmlNameTable
Het XmlNameTable te gebruiken om tekenreeksen te atomiseren. Als dit het is null, wordt in plaats daarvan de naamtabel gebruikt die wordt gebruikt om de nsMgr tabel te maken. Zie voor meer informatie over atomiseerde tekenreeksen XmlNameTable.
- nsMgr
- XmlNamespaceManager
De XmlNamespaceManager te gebruiken functie voor het opzoeken van naamruimtegegevens of null.
- docTypeName
- String
De naam van de declaratie van het documenttype.
- pubId
- String
De openbare id.
- sysId
- String
De systeem-id.
- internalSubset
- String
De interne DTD-subset. De DTD wordt gebruikt voor entiteitsomzetting, niet voor documentvalidatie.
- baseURI
- String
De basis-URI voor het XML-fragment (de locatie van waaruit het fragment is geladen).
- xmlLang
- String
Het xml:lang bereik.
Uitzonderingen
nt is niet hetzelfde XmlNameTable dat wordt gebruikt om te bouwen nsMgr.