XmlParserContext コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した値を使用して、 XmlParserContext クラスの新しいインスタンスを初期化します。
オーバーロード
| 名前 | 説明 |
|---|---|
| XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace) |
指定した |
| XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace, Encoding) |
指定した |
| XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace) |
指定した |
| XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace, Encoding) |
指定した |
XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace)
指定したXmlParserContext、XmlNameTable、XmlNamespaceManager、およびxml:lang値を使用して、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)
パラメーター
- nt
- XmlNameTable
文字列のアトミック化に使用する XmlNameTable 。 これが null場合は、代わりに nsMgr の構築に使用される名前テーブルが使用されます。 アトミック化された文字列の詳細については、「 XmlNameTable」を参照してください。
- nsMgr
- XmlNamespaceManager
名前空間情報の検索またはXmlNamespaceManagerに使用するnull。
- xmlLang
- String
xml:lang スコープ。
例外
ntは、XmlNameTableの構築に使用されるのと同じnsMgrではありません。
例
次の例では、XML フラグメントを読み取ります。
XmlParserContextとそのXmlNamespaceManagerを使用して名前空間の照合を処理します。
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
適用対象
XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace, Encoding)
指定したXmlParserContext、XmlNameTable、XmlNamespaceManager、xml:lang、エンコードを使用して、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)
パラメーター
- nt
- XmlNameTable
文字列のアトミック化に使用する XmlNameTable 。 これが null場合は、代わりに nsMgr の構築に使用される名前テーブルが使用されます。 アトミック化された文字列の詳細については、「 XmlNameTable」を参照してください。
- nsMgr
- XmlNamespaceManager
名前空間情報の検索またはXmlNamespaceManagerに使用するnull。
- xmlLang
- String
xml:lang スコープ。
例外
ntは、XmlNameTableの構築に使用されるのと同じnsMgrではありません。
適用対象
XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace)
指定したXmlParserContext、XmlNameTable、基本 URI、XmlNamespaceManager、xml:lang、ドキュメント型の値を使用して、xml: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)
パラメーター
- nt
- XmlNameTable
文字列のアトミック化に使用する XmlNameTable 。 これが null場合は、代わりに nsMgr の構築に使用される名前テーブルが使用されます。 アトミック化された文字列の詳細については、「 XmlNameTable」を参照してください。
- nsMgr
- XmlNamespaceManager
名前空間情報の検索またはXmlNamespaceManagerに使用するnull。
- docTypeName
- String
ドキュメント型宣言の名前。
- pubId
- String
パブリック識別子。
- sysId
- String
システム識別子。
- internalSubset
- String
内部 DTD サブセット。 DTD サブセットは、ドキュメントの検証ではなく、エンティティ解決に使用されます。
- baseURI
- String
XML フラグメントのベース URI (フラグメントの読み込み元の場所)。
- xmlLang
- String
xml:lang スコープ。
例外
ntは、XmlNameTableの構築に使用されるのと同じnsMgrではありません。
例
次の例では、 XmlParserContext を使用して 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
注釈
このコンストラクターは、DocumentTypeに必要なすべてのXmlValidatingReader情報を提供します。 この XmlParserContext が XmlTextReaderに渡された場合、すべての DTD 情報は無視されます。
DTD を internalSubsetとして渡すと、DTD はドキュメントの検証ではなくエンティティ解決に使用されます。
適用対象
XmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace, Encoding)
指定したXmlParserContext、XmlNameTable、基本 URI、XmlNamespaceManager、xml:lang、エンコード、ドキュメント型の値を使用して、xml: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, 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)
パラメーター
- nt
- XmlNameTable
文字列のアトミック化に使用する XmlNameTable 。 これが null場合は、代わりに nsMgr の構築に使用される名前テーブルが使用されます。 アトミック化された文字列の詳細については、「 XmlNameTable」を参照してください。
- nsMgr
- XmlNamespaceManager
名前空間情報の検索またはXmlNamespaceManagerに使用するnull。
- docTypeName
- String
ドキュメント型宣言の名前。
- pubId
- String
パブリック識別子。
- sysId
- String
システム識別子。
- internalSubset
- String
内部 DTD サブセット。 DTD は、ドキュメントの検証ではなく、エンティティ解決に使用されます。
- baseURI
- String
XML フラグメントのベース URI (フラグメントの読み込み元の場所)。
- xmlLang
- String
xml:lang スコープ。
例外
ntは、XmlNameTableの構築に使用されるのと同じnsMgrではありません。