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);
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.