XmlParserContext Class has context information required by the XmlReader to parse an XML fragment.
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
Dim xmlFrag As String = "<item rk:ID='abc-23'>A</item><item rk:ID='r2-435'>B</item><item rk:ID='abc-39'>C</item>"
Dim nt As New NameTable()
Dim nsmgr As New XmlNamespaceManager(nt)
nsmgr.AddNamespace("rk", "urn:store-items")
Dim context As New XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
Dim settings As New XmlReaderSettings()
settings.ConformanceLevel = ConformanceLevel.Fragment
Dim reader As XmlReader = XmlReader.Create(New StringReader(xmlFrag), settings, context)
End Sub
End Class
Related examples in the same category