Extensions.XPathSelectElement selects XElement using a XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver.
Imports System
Imports System.Xml
Imports System.Xml.XPath
Public Class MainClass
Public Shared Sub Main()
Dim markup As XElement = _
<aw:Root xmlns:aw='http://www.domain.com'>
<aw:Child1>child one data</aw:Child1>
<aw:Child2>child two data</aw:Child2>
</aw:Root>
Dim reader As XmlReader = markup.CreateReader
Dim nameTable As XmlNameTable = reader.NameTable
Dim namespaceManager As XmlNamespaceManager = New XmlNamespaceManager(nameTable)
namespaceManager.AddNamespace("aw", "http://www.domain.com")
Dim child1 As XElement = markup.XPathSelectElement("./aw:Child1", namespaceManager)
Console.WriteLine(child1)
End Sub
End Class
Related examples in the same category