I'm trying to figure out the best way (considering there could be instances
where I get a lot of data in this XML, and I want to minimize any slowdowns)
to extract the value of one particular node from an XML string (not saved as
a file, but passed as a string from another module).
For example, let's assume I get back XML in a string that looks like this:
<Commands>
<cmd name="1">
<item name="result">Complete</item>
</cmd>
<cmd name="2">
<item name="result">Returned</item>
<item name="id">12345</item>
</cmd>
<cmd name="3">
<item name="result">Tested</item>
</cmd>
</Commands>
I need an efficient way that I can (for example) return the value from the
cmd tag with name attribute "2", and then the item tag below that with the
name attribute "result" (in other words, for this case giving the string
"Returned".
What is going to be the best way to do this? It was suggested (here) that I
use the XmlTextReader, but I'm not totally sure how that would work.
Can anyone help?
Ideally I'd like a function (VB.NET) that takes the xml as one parameter (as
a string), and the cmd "name" as another parameter (also as a string), and
the item "name" as the third parameter, and returns a string containing the
value.
Thanks!
-Scott