Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have below XML. I want to get the value of element name="PropertyName". whose value is 117 Executive Drive. How i can get this?

XML
<complexType>
<sequence>
  <element name="PropertyName" type="string" use="required" value="117 Executive Drive" />
  <element name="PropertyID" type="string" use="required" value="2" />
 <element name="BuildingInformation">
 <complexType>
 </sequence>
</complexType>
Posted
Comments
Tomas Takac 13-May-15 3:58am    
What have you tried so far? Can you show your code?

You can use XPath
XML
"/complexType/sequence/element[@value='117 Executive Drive']/@name"
to get the desired result
 
Share this answer
 
Comments
Maciej Los 13-May-15 5:27am    
+5!
You can use XDocument[^] + Linq query:

C#
XDocument xDoc = XDocument.Load("FullFileName.xml");
var qry = xDoc
    .Root
    .Descendants("element")
    .Where(n=>n.Attribute("value").Value=="117 Executive Drive")
    .Select(n=.n.Attribute("name").Value);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900