public class XmlParserContext
|
ctor #1 | Overloaded:.ctor(XmlNameTable nt, XmlNamespaceManager nsMgr, string xmlLang, XmlSpace xmlSpace) Initializes a new instance of the XmlParserContext class with the specified values. |
ctor #2 | Overloaded:.ctor(XmlNameTable nt, XmlNamespaceManager nsMgr, string xmlLang, XmlSpace xmlSpace, Encoding enc) Initializes a new instance of the XmlParserContext class with the specified values. |
ctor #3 | Overloaded:.ctor(XmlNameTable nt, XmlNamespaceManager nsMgr, string docTypeName, string pubId, string sysId, string internalSubset, string baseURI, string xmlLang, XmlSpace xmlSpace) Initializes a new instance of the XmlParserContext class with the specified values. |
ctor #4 | Overloaded:.ctor(XmlNameTable nt, XmlNamespaceManager nsMgr, string docTypeName, string pubId, string sysId, string internalSubset, string baseURI, string xmlLang, XmlSpace xmlSpace, Encoding enc) Initializes a new instance of the XmlParserContext class with the specified values. |
BaseURI | Read-write Gets or sets the base URI. |
DocTypeName | Read-write Gets or sets the name of the document type declaration. |
Encoding | Read-write |
InternalSubset | Read-write Gets or sets the internal DTD subset. |
NamespaceManager | Read-write Gets or sets the XmlNamespaceManager. |
NameTable | Read-write Gets the XmlNameTable used to atomize strings. For more information on atomized strings, see XmlNameTable. |
PublicId | Read-write Gets or sets the public identifier. |
SystemId | Read-write Gets or sets the system identifier. |
XmlLang | Read-write Gets or sets the current xml:lang scope. |
XmlSpace | Read-write Gets or sets the current xml:space scope. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public XmlParserContext( |
nt
nsMgr
xmlLang
xmlSpace
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { XmlValidatingReader 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 XmlValidatingReader(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 (reader.Prefix==String.Empty) 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
public XmlParserContext( |
nt
nsMgr
xmlLang
xmlSpace
enc
public XmlParserContext( |
nt
nsMgr
docTypeName
pubId
sysId
internalSubset
baseURI
xmlLang
xmlSpace
If nt and the name table used to construct the nsMgr are not the same, XmlParserContext does not recognize namespaces added to nsMgr and throws an XmlException when it encounters the unrecognized namespaces.
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { XmlValidatingReader 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 XmlValidatingReader(xmlFrag, XmlNodeType.Element, context); reader.ValidationType = ValidationType.None; //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
public XmlParserContext( |
nt
nsMgr
docTypeName
pubId
sysId
internalSubset
baseURI
xmlLang
xmlSpace
enc
public string BaseURI {get; set;}
|
public string DocTypeName {get; set;}
|
public Encoding Encoding {get; set;}
|
public string InternalSubset {get; set;}
|
public XmlNamespaceManager NamespaceManager {get; set;}
|
public XmlNameTable NameTable {get; set;}
|
public string PublicId {get; set;}
|
public string SystemId {get; set;}
|
public string XmlLang {get; set;}
|
public XmlSpace XmlSpace {get; set;}
|
~XmlParserContext(); |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
public virtual string ToString(); |