C# - Access XML attributes -
i want access attribute type
value of abc
female
xelement xelement = xelement.load("..\\..\\employees.xml"); var name = nm in xelement.elements("employee") (string)nm.(element("abc") == "female").attribute("type") == "att" select nm;
this didn't work. way make happen?
something work. useful see xml though.
var doc = xdocument.load("c:\\temp\\test.xml"); var result = doc.descendants("employee") .where(x=>(string)x.value== "female") .select(x=>x.attribute("type").value);
this assuming xml this, query return "foo1".
<?xml version="1.0"?> <root>- <employee type="foo"> <abc>male</abc> </employee> <employee type="foo1"> <abc>female</abc> </employee> <employee type="foo2"> <abc>male</abc> </employee> </root>
Comments
Post a Comment