XmlParserContext Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Provides all the context information required by the XmlReader to parse an XML fragment.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

System.Object
  System.Xml.XmlParserContext

public class XmlParserContext

NameDescription
System_CAPS_pubmethodXmlParserContext(XmlNameTable, XmlNamespaceManager, String, String, String, String, String, String, XmlSpace)

Initializes a new instance of the XmlParserContext class with the specified XmlNameTable, XmlNamespaceManager, base URI, xml:lang, xml:space, and document type values.

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

Initializes a new instance of the XmlParserContext class with the specified XmlNameTable, XmlNamespaceManager, base URI, xml:lang, xml:space, encoding, and document type values.

System_CAPS_pubmethodXmlParserContext(XmlNameTable, XmlNamespaceManager, String, XmlSpace)

Initializes a new instance of the XmlParserContext class with the specified XmlNameTable, XmlNamespaceManager, xml:lang, and xml:space values.

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

Initializes a new instance of the XmlParserContext class with the specified XmlNameTable, XmlNamespaceManager, xml:lang, xml:space, and encoding.

NameDescription
System_CAPS_pubpropertyBaseURI

Gets or sets the base URI.

System_CAPS_pubpropertyDocTypeName

Gets or sets the name of the document type declaration.

System_CAPS_pubpropertyEncoding

Gets or sets the encoding type.

System_CAPS_pubpropertyInternalSubset

Gets or sets the internal DTD subset.

System_CAPS_pubpropertyNamespaceManager

Gets or sets the XmlNamespaceManager.

System_CAPS_pubpropertyNameTable

Gets the XmlNameTable used to atomize strings. For more information on atomized strings, see XmlNameTable.

System_CAPS_pubpropertyPublicId

Gets or sets the public identifier.

System_CAPS_pubpropertySystemId

Gets or sets the system identifier.

System_CAPS_pubpropertyXmlLang

Gets or sets the current xml:lang scope.

System_CAPS_pubpropertyXmlSpace

Gets or sets the current xml:space scope.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

The following example creates an XmlReader object that reads an XML fragment.

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);

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: