XmlParserContext 类

定义

提供分析 XML 片段所需的所有 XmlReader 上下文信息。

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, Encoding)

使用指定的XmlParserContext、基 URI、、XmlNameTable编码XmlNamespaceManager和文档类型值初始化类的新实例xml:langxml:space

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

使用指定的XmlParserContext、基 URI、XmlNameTableXmlNamespaceManager和文档类型值初始化类的新实例xml:langxml:space

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

使用指定的XmlParserContextXmlNameTableXmlNamespaceManagerxml:lang和编码初始化类的新实例xml:space

XmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace)

使用指定的、XmlParserContext值和XmlNameTable值初始化类的新实例XmlNamespaceManagerxml:langxml:space

属性

名称 说明
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)

适用于