XmlParserContext Constructor (XmlNameTable, XmlNamespaceManager, String, XmlSpace)
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Initializes a new instance of the XmlParserContext class with the specified XmlNameTable, XmlNamespaceManager, xml:lang, and xml:space values.
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Syntax
'Declaration
Public Sub New ( _
nt As XmlNameTable, _
nsMgr As XmlNamespaceManager, _
xmlLang As String, _
xmlSpace As XmlSpace _
)
public XmlParserContext(
XmlNameTable nt,
XmlNamespaceManager nsMgr,
string xmlLang,
XmlSpace xmlSpace
)
Parameters
- nt
Type: System.Xml.XmlNameTable
The XmlNameTable to use to atomize strings. If this is nulla null reference (Nothing in Visual Basic), the name table used to construct the nsMgr is used instead. For more information about atomized strings, see XmlNameTable.
- nsMgr
Type: System.Xml.XmlNamespaceManager
The XmlNamespaceManager to use for looking up namespace information, or nulla null reference (Nothing in Visual Basic).
- xmlLang
Type: System.String
The xml:lang scope.
- xmlSpace
Type: System.Xml.XmlSpace
An XmlSpace value indicating the xml:space scope.
Exceptions
Exception | Condition |
---|---|
XmlException | nt is not the same XmlNameTable used to construct nsMgr. |
Examples
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
Using reader As XmlReader = XmlReader.Create(New StringReader(xmlFrag), settings, context)
End Using
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;
using (XmlReader reader = XmlReader.Create(new StringReader(xmlFrag), settings, context))
{
}
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.