I have the following xml:
<?xml version="1.0" encoding="UTF-8"?>
<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
<gesmes:subject>Reference rates</gesmes:subject>
<gesmes:Sender>
<gesmes:name>European Central Bank</gesmes:name>
</gesmes:Sender>
<Cube>
<Cube time='2016-09-12'>
<Cube currency='USD' rate='1.1226'/>
<Cube currency='JPY' rate='114.38'/>
</Cube>
</Cube>
</gesmes:Envelope>
I want to get attribute value of each currency. For now I am using this but it doesn't work:
Dim xmlTree1 As New XmlDocument()
xmlTree1.Load("C:\\download\eurofxref-daily.xml")
Dim currencyUSD As String = xmlTree1.SelectSingleNode("/gesmes:Envelope/Cube/Cube/Cube[@currency='USD']/@rate").Value
Dim currencyJPY As String = xmlTree1.SelectSingleNode("/gesmes:Envelope/Cube/Cube/Cube[@currency='JPY']/@rate").Value
gesmesprefix needs to be registered with the namespace. See this article on using the namespace manager support.microsoft.com/en-us/kb/318545