get xml node value from xml string



I have xml which contain xml namespace. i need to get value from its xml node



<personxml:person xmlns:personxml="http://ift.tt/1BshPte" xmlns:cityxml="http://ift.tt/1BshOWe">
<personxml:name>Rob</personxml:name>
<personxml:age>37</personxml:age>
<cityxml:homecity>
<cityxml:name>London</cityxml:name>
<cityxml:lat>123.000</cityxml:lat>
<cityxml:long>0.00</cityxml:long>
</cityxml:homecity>


Now i want to get value of tag <cityxml:lat> as 123.00


Code :



string xml = "<personxml:person xmlns:personxml='http://ift.tt/1BshPte' xmlns:cityxml='http://ift.tt/1BshOWe'><personxml:name>Rob</personxml:name><personxml:age>37</personxml:age><cityxml:homecity><cityxml:name>London</cityxml:name><cityxml:lat>123.000</cityxml:lat><cityxml:long>0.00</cityxml:long></cityxml:homecity></personxml:person>";
var elem = XElement.Parse(xml);
var value = elem.Element("OTA_personxml/cityxml:homecity").Value;


Error i am getting



The '/' character, hexadecimal value 0x2F, cannot be included in a name.

No comments:

Post a Comment