EDN Admin
Well-known member
Hi,
Im trying to select a node list from a xml file with no success. This file have xmlns attribute.
The code i am using is this one:
<pre class="prettyprint System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
xml.Load(FilePath);
XmlNamespaceManager nsmanager = new XmlNamespaceManager(xml.NameTable);
nsmanager.AddNamespace("soap", "http://www.w3.org/2003/05/soap-envelope");
nsmanager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
nsmanager.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
XmlNodeList xnList = xml.DocumentElement.SelectNodes("/soap:Envelope/soap:Body/GetServicesPricesAndAvailabilityResponse/GetServicesPricesAndAvailabilityResult/Services/PriceAndAvailabilityService", nsmanager);
string value = xnList[0]["ServiceId"].InnerText; // ERROR (NODES COUNT == 0)[/code]
The xml file i am using is this one:
<pre class="prettyprint <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema
<soap:Body>
<GetServicesPricesAndAvailabilityResponse xmlns="http://tempuri.org/
<GetServicesPricesAndAvailabilityResult>
<Errors />
<Services>
<PriceAndAvailabilityService>
<ServiceID>9654</ServiceID>
.......
.......
.......
</PriceAndAvailabilityService>
</Services>
</GetServicesPricesAndAvailabilityResult>
</GetServicesPricesAndAvailabilityResponse>
</soap:Body>
</soap:Envelope>[/code]
<br/>
I am trying to access ServiceID node.
Regards,
JP.
View the full article
Im trying to select a node list from a xml file with no success. This file have xmlns attribute.
The code i am using is this one:
<pre class="prettyprint System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
xml.Load(FilePath);
XmlNamespaceManager nsmanager = new XmlNamespaceManager(xml.NameTable);
nsmanager.AddNamespace("soap", "http://www.w3.org/2003/05/soap-envelope");
nsmanager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
nsmanager.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
XmlNodeList xnList = xml.DocumentElement.SelectNodes("/soap:Envelope/soap:Body/GetServicesPricesAndAvailabilityResponse/GetServicesPricesAndAvailabilityResult/Services/PriceAndAvailabilityService", nsmanager);
string value = xnList[0]["ServiceId"].InnerText; // ERROR (NODES COUNT == 0)[/code]
The xml file i am using is this one:
<pre class="prettyprint <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema
<soap:Body>
<GetServicesPricesAndAvailabilityResponse xmlns="http://tempuri.org/
<GetServicesPricesAndAvailabilityResult>
<Errors />
<Services>
<PriceAndAvailabilityService>
<ServiceID>9654</ServiceID>
.......
.......
.......
</PriceAndAvailabilityService>
</Services>
</GetServicesPricesAndAvailabilityResult>
</GetServicesPricesAndAvailabilityResponse>
</soap:Body>
</soap:Envelope>[/code]
<br/>
I am trying to access ServiceID node.
Regards,
JP.
View the full article