문제

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top