Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

XML searching the contents based on the key (XPATH)

$
0
0

Hi all of you,

This is my XML:

<countries>
  <country code="AF" iso="4">Afghanistan</country>
  <country code="AL" iso="8">Albania</country>
  <country code="DZ" iso="12">Algeria</country>
  <country code="AS" iso="16">American Samoa</country>

..

..

</countries>

Using XPath, how can I retrieve -for example- Albania using prefix "AL"??

I use these statements when I want to retrieve the value of the key directly (it is other XML):

<?xml version="1.0" encoding="utf-8"?>
<PanelesXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Section0>OR</Section0>
<Section1>Stock de articulos</Section1>
<Section2>Chapa y pintura</Section2>
<Section3>Top operarios</Section3>

..

</PanelesXML>

    Dim MyDoc As XPathDocument = New XPathDocument(My.Application.Info.DirectoryPath & "XML\Paneles.xml")
    Dim MyNav As XPathNavigator = MyDoc.CreateNavigator()
    Dim sValue as String = MyNav.SelectSingleNode("//Section0").ToString

Thank you so much for sharing the knowledge,


Primary platform is Windows 7 Ultimate 64 bit along with VS 2012/Sql2k8 for WPF/SilverLight projects.


Viewing all articles
Browse latest Browse all 8156

Trending Articles