Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
WebResponse response = req.GetResponse();

Stream responseStream = (response.GetResponseStream());
XmlDocument xDoc = new XmlDocument();

XmlTextReader myXMLReader = null;
myXMLReader = new XmlTextReader(response.GetResponseStream());

xDoc.Load(myXMLReader);

In myXMLReader i m getting none but xDoc do have innertext as xml document.
i wan to use this xdoc to create a datatable but nodes doesnot get selected.
I use following code but it give 0 always inspite of having data in my xdoc.

int f = (xDoc.SelectNodes("//Result/node()")).Count;

my xmldocument(xDoc) document is like
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><SearchResponse xmlns="http://stellatravelgateway.stellatravelservices.co.uk/AirService"><SearchResult Success="true" ErrorCode="0" ErrorDescription="" ResultSetID="41584558-7197-4d79-a45b-17a83c1936b3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Results><Result><AirResult ResultItemID="0" Operator="BA" From="LGW" To="BCN" FromName="London Gatwick, London, Great Britain" ToName="Barcelona, Barcelona, Spain" AirlineClass="O" OperatorName="British Airways" CabinClass="Economy" HasAvailability="true" FareType="Published" MinStayCode="" MaxStayCode="" MinStayDescription="" MaxStayDescription="" AdultGross="61.50" AdultTax="78.59" AdultTotal="140.09" AdultCommission="0.00" ChildGross="61.50" ChildTax="78.59" ChildTotal="140.09" ChildCommission="0.00" InfantGross="10.00" InfantTax="37.59" InfantTotal="47.59" InfantCommission="0.00" TotalGross="133.00" TotalCommission="0.00" TotalTax="194.77" AdultPaxCount="1" ChildPaxCount="1" InfantPaxCount="1"><Conditions>...........


ifound that this namespace line is crteating problem .
<SearchResponse xmlns="http://stellatravelgateway.stellatravelservices.co.uk/AirService">


i want to use foreach loop on nodes.

what to do with this
Please help
Posted
Updated 17-Feb-14 1:21am
v2

1 solution

try this one it is working in my code but you need to understand which tag you need to display

HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
      HttpWebResponse response = request.GetResponse() as HttpWebResponse;

      XmlDocument xmlDoc = new XmlDocument();
      xmlDoc.Load(response.GetResponseStream());
      return xmlDoc.DocumentElement.SelectSingleNode("results");



hear results is my actual result which i need in my project so i take result
 
Share this answer
 
v2
Comments
hrishisinha 17-Feb-14 7:23am    
i have updated my question plz look at the update once

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