This is embarrassing. I have an XML string which comes to me as part of a network operation.
<?xml version="1.0" encoding="UTF-8"?>
+61xxxxxxxxxxD370532E-xxxx-41B9-xxxx-37BCF1B2C9520000Success0.0770<currency_symbol>$</currency_symbol><currency_type>AUD</currency_type>
I have the following code to get each “terminal” item and corresponding datum:-
try
rd.LoadXml(source)
catch e as XmlException
msgBox "Could not load XML from source"
return
end try
root = rd.FirstChild
messages = root.FirstChild
items = messages.FirstChild
for i as integer = 0 to items.ChildCount - 1
item = items.child(i).Name //provides the name properly, with no tags associated, e.g. price
datum = items.child(i).toString // works but has tags e.g. <price>0.0770</price>
next
return
The issue comes with the line :- datum = items.child(i).toString
This at least gets me the value associated with the item, but it is not the clean value - it has tags around it, e.g. 0.0770
datum = items.child(i).value //does not work (no text returned)
datum = items.child(i).getAttribute(item) //does not work (no text returned)
What might be the secret sauce that gets me the value associated with the item, in a clean way ?
I appreciate that the code does no recursion and might not be appropriate for other XML strings. That is understood.
Regards,
Tony Barry
Sydney