user3652973
user3652973

Reputation: 59

Extracting Xml Elements from Outerxml type

Probably another easy one but I cant find the answer and cant work it out.

I have a outerxml packet for example

<field1 id="abc" passed="False">
  <field2 id="BCD" reason="yada"/>
</field1>

in asp.net (c#) how can I retrieve the value of "reason"?

Upvotes: 1

Views: 1247

Answers (1)

Yuval Itzchakov
Yuval Itzchakov

Reputation: 149598

You can use LINQ to XML:

string reason = (string)xml.Element("field1").Element("field2").Attribute("reason");

Upvotes: 1

Related Questions