Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Initialisiert eine neue Instanz der XmlParserContext-Klasse mit den angegebenen Werten für XmlNameTable, XmlNamespaceManager, Basis-URI, xml:lang, xml:space und Dokumenttyp.
Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)
Syntax
'Declaration
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 _
)
'Usage
Dim nt As XmlNameTable
Dim nsMgr As XmlNamespaceManager
Dim docTypeName As String
Dim pubId As String
Dim sysId As String
Dim internalSubset As String
Dim baseURI As String
Dim xmlLang As String
Dim xmlSpace As XmlSpace
Dim instance As New XmlParserContext(nt, nsMgr, docTypeName, pubId, sysId, internalSubset, baseURI, xmlLang, xmlSpace)
public XmlParserContext (
XmlNameTable nt,
XmlNamespaceManager nsMgr,
string docTypeName,
string pubId,
string sysId,
string internalSubset,
string baseURI,
string xmlLang,
XmlSpace xmlSpace
)
public:
XmlParserContext (
XmlNameTable^ nt,
XmlNamespaceManager^ nsMgr,
String^ docTypeName,
String^ pubId,
String^ sysId,
String^ internalSubset,
String^ baseURI,
String^ xmlLang,
XmlSpace xmlSpace
)
public XmlParserContext (
XmlNameTable nt,
XmlNamespaceManager nsMgr,
String docTypeName,
String pubId,
String sysId,
String internalSubset,
String baseURI,
String xmlLang,
XmlSpace xmlSpace
)
public function XmlParserContext (
nt : XmlNameTable,
nsMgr : XmlNamespaceManager,
docTypeName : String,
pubId : String,
sysId : String,
internalSubset : String,
baseURI : String,
xmlLang : String,
xmlSpace : XmlSpace
)
Parameter
- nt
Die zum Atomisieren von Zeichenfolgen zu verwendende XmlNameTable. Wenn diese NULL (Nothing in Visual Basic) ist, wird stattdessen die Namenstabelle zum Erstellen von nsMgr verwendet. Weitere Informationen zu atomisierten Zeichenfolgen finden Sie unter XmlNameTable.
- nsMgr
Der XmlNamespaceManager, der für die Suche nach Namespaceinformationen verwendet werden soll, oder NULL (Nothing in Visual Basic).
- docTypeName
Der Name der Dokumenttypdeklaration.
- pubId
Der öffentliche Bezeichner.
- sysId
Der Systembezeichner.
- internalSubset
Die Teilmenge der internen DTD.
- baseURI
Der Basis-URI für das XML-Fragment (der Speicherort, aus dem das Fragment geladen wurde).
- xmlLang
Der xml:lang-Bereich.
- xmlSpace
Ein XmlSpace-Wert, der den xml:space-Bereich angibt.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Bei nt handelt es sich nicht um die gleiche XmlNameTable, die zum Erstellen von nsMgr verwendet wird. |
Hinweise
Dieser Konstruktor stellt sämtliche von XmlValidatingReader benötigten DocumentType-Informationen bereit. Beim Übergeben dieses XmlParserContext an einen XmlTextReader werden sämtliche DTD-Informationen ignoriert.
Beispiel
Im folgenden Beispiel wird ein XmlParserContext zum Lesen eines XML-Fragments gelesen.
Option Explicit On
Option Strict On
Imports System
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 'Main
End Class 'Sample
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
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
XmlParserContext-Klasse
XmlParserContext-Member
System.Xml-Namespace