I have a set of xml that i have in an XElement that looks like this:
<Object type="Item_Element">
<Property name="IDValue1" value="somevaluethatihave"/>
<Property name="IDValue2" value="somevaluethatineed"/>
<Property name="IDValue3" value="somevaluethatihaveanddonotneed"/>
</Object>
I would like to get the value attribute value of IDValue2 as a string instead of as an XElement
I have tried doing so with this:
var meID = from el in linkedTeethInfo.DescendantsAndSelf("Property")
where (string)el.Attribute("name") == "IDValue2"
select el.Attribute("value");
As well as some other combinations that did not work and kept returning it in the XElement format listed as an index value. I was wondering if it would be possible to get the single value somevaluethatineed as a string? I would preferably like to have this using one variable and not have to break this down into multiple steps.
XElement.Attributereturns anXAttribute: Are you sure you're getting anXElementbecause that's not what the quoted code will return (IEnumerable<XAttribute>). Have you considered getting theValueproperty of each returned node?XAttribute. Like I said, I am still trying to get my barrings with all of this. I have also tried getting theValueand it leaves me in the same position.