How to retrieve an element value from the xml using xpath?

Jfcslwaawcjcr

New Member
How to retrieve the sitename element value from the below xml?\[code\]<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:63630/Service.svc</To> <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IService/GetDemographic</Action> </s:Header> <s:Body> <GetDemographic xmlns="http://tempuri.org/"> <userIdentifier>first value</userIdentifier> <sitename>second value</sitename> <demographicName>third value</demographicName> </GetDemographic> </s:Body></s:Envelope>\[/code\]The below code I tried returned null:\[code\]var xmlDocument = new XmlDocument();xmlDocument.LoadXml(myXml);var result = xmlDocument.SelectNodes("//sitename");\[/code\]Is the problem the Xml Namespace? Could I search regardless of the namespace values as sitename element has no namespace assigned to it?I found the below code which works fine:\[code\]xmlDocument.SelectNodes("//*[local-name()='sitename']");\[/code\]How to make it case-insensitive?
 
Back
Top