1

How can I get the value of title1 from this string in a datatable using xDocument

<Person ActionType = "Update"  Title1="Miss" />

I tried descendants, XAttributes and all sorts...Maybe input is wrong but

XDocument xml = XDocument.Parse(row["XMLTransaction"].ToString());

IEnumerable<XAttribute> query =
from transaction in xml.Root.Elements()
select transaction.Attribute(attribute);
AakashM
  • 62,551
  • 17
  • 151
  • 186
insanepaul
  • 187
  • 2
  • 5
  • 17

1 Answers1

1

If that string is your literal XML then you should omit the .Elements() part.

Even shorter with XElement instead of XDocument :

 var xml = XElement.Parse(row["XMLTransaction"].ToString());

 IEnumerable<XAttribute> query = xml.Attributes();
H H
  • 263,252
  • 30
  • 330
  • 514