Reputation: 6557
I recieve this piece of xml:
<hash>
<base>XPM</base>
<alt>BTC</alt>
<value type="decimal">0.00341</value>
</hash>
How do I get the values of base, alt and value tags? I would also like to know that the type attribute is decimal.
Upvotes: 1
Views: 720
Reputation: 309
You can use the XPath:
Get alt nodes - //hash/alt
Get value nodes with type="decimal" - //hash/value[@type="decimal"]
Upvotes: 1
Reputation: 32797
You can use LINQ2XML
XElement node=XElement.Parse(input);
node.Element("base").Value;
node.Element("alt").Value;
node.Element("value").Attributes("type").Value;//attribute value
node.Element("value").Value;
Upvotes: 6