XmlParserContext 類別

定義

提供 XmlReader 所需的所有內容資訊以剖析 XML 片段。

public ref class XmlParserContext
public class XmlParserContext
type XmlParserContext = class
Public Class XmlParserContext
繼承
XmlParserContext

範例

下列範例會建立讀取 XmlReader XML 片段的物件。

string xmlFrag ="<item rk:ID='abc-23'>hammer</item> " +
                        "<item rk:ID='r2-435'>paint</item>" +
                        "<item rk:ID='abc-39'>saw</item>";

// Create the XmlNamespaceManager.
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("rk", "urn:store-items");

// Create the XmlParserContext.
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

// Create the reader.
XmlReaderSettings settings = new XmlReaderSettings();
settings.ConformanceLevel = ConformanceLevel.Fragment;
XmlReader reader = XmlReader.Create(new StringReader(xmlFrag), settings, context);
Dim xmlFrag As String = "<item rk:ID='abc-23'>hammer</item> " & _
                                     "<item rk:ID='r2-435'>paint</item>" & _
                                     "<item rk:ID='abc-39'>saw</item>"

' Create the XmlNamespaceManager.
Dim nt As New NameTable()
Dim nsmgr As New XmlNamespaceManager(nt)
nsmgr.AddNamespace("rk", "urn:store-items")

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

' Create the reader. 
Dim settings As New XmlReaderSettings()
settings.ConformanceLevel = ConformanceLevel.Fragment
Dim reader As XmlReader = XmlReader.Create(New StringReader(xmlFrag), settings, context)

建構函式

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

使用指定的 XmlNameTableXmlNamespaceManager、基底 URI、xml:langxml:space 和文件類型的值,初始化 XmlParserContext 類別的新執行個體。

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

使用指定的 XmlNameTableXmlNamespaceManager、基底 URI、xml:langxml:space、編碼方式和文件類型的值,初始化 XmlParserContext 類別的新執行個體。

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace)

使用指定的 XmlNameTableXmlNamespaceManagerxml:langxml:space 的值,初始化 XmlParserContext 類別的新執行個體。

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

使用指定的 XmlNameTableXmlNamespaceManagerxml:langxml:space 和編碼方式,初始化 XmlParserContext 類別的新執行個體。

屬性

BaseURI

取得或設定基底 URI。

DocTypeName

取得或設定文件類型宣告的名稱。

Encoding

取得或設定編碼類型。

InternalSubset

取得或設定內部 DTD 子集。

NamespaceManager

取得或設定 XmlNamespaceManager

NameTable

取得用來儘量縮減字串的 XmlNameTable。 如需已儘量縮減之字串的詳細資訊,請參閱 XmlNameTable

PublicId

取得或設定公用識別碼。

SystemId

取得或設定系統識別碼。

XmlLang

取得或設定目前的 xml:lang 範圍。

XmlSpace

取得或設定目前的 xml:space 範圍。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於