Reputation: 11
I have the follwing XML:
<?xml version="1.0" encoding="utf-8" ?>
<configuracoes>
<gerais>
<atualizacoes>
<tipo>automática</tipo>
<frequencia>diária</frequencia>
</atualizacoes>
</gerais>
</configuracoes>
And the code:
Dim xPathNavigator As XPathNavigator
Dim xPathNodeIterator As XPathNodeIterator
xPathNavigator = Me.XML.CreateNavigator()
xPathNodeIterator = xPathNavigator.Select("/configuracoes/gerais/atualizacoes")
While (xPathNodeIterator.MoveNext())
Dim xPathNavigatorInterno As XPathNavigator = xPathNodeIterator.Current
MsgBox(xPathNavigatorInterno.Value) 'It Shows "automáticadiária" instead of "automática" and then "diária" in the next iteration...
End While
I want to get in the first iteration "automática" and then, in the last one "diária". What's wrong? How could I solve that? Thank you.
Upvotes: 1
Views: 627
Reputation: 21304
Another consideration moving forward is to use LINQ to XML rather than XPath. In my experience it is much easier to use and navigate XML via queries than iterating through it like XPath does. For future reference take a look at the link below:
Overview of LINQ to XML in Visual Basic:
http://msdn.microsoft.com/en-us/library/bb384460.aspx
Upvotes: 0
Reputation: 338208
Try
/configuracoes/gerais/atualizacoes/*
The Value
of a node always is the concatented value of all descendant text nodes. This is analoguous to HTML, where the value of
<div>This is some <b>bold</b> text.</div>
is "This is some bold text."
.
If you want the indiviual values, select the individual nodes explicitly. In your case, since they have different names, I used the *
.
Upvotes: 1