Read and parse XML from Web Service using C# in ASP.Net

Last Reply one year ago By Mudassar

Posted one year ago

I am trying to read xml from service .Below is the xml response fom service.

<DataSet xmlns="http://tempuri.org/">
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="No" type="xs:string" minOccurs="0"/>
<xs:element name="AcName" type="xs:string" minOccurs="0"/>
<xs:element name="PartNo" type="xs:short" minOccurs="0"/>
<xs:element name="Station" type="xs:string" minOccurs="0"/>
<xs:element name="SlNo" type="xs:short" minOccurs="0"/>
<xs:element name="SectionName" type="xs:string" minOccurs="0"/>
<xs:element name="FistName" type="xs:string" minOccurs="0"/>
<xs:element name="LastName" type="xs:string" minOccurs="0"/>
<xs:element name="RelationFirstName" type="xs:string" minOccurs="0"/>
<xs:element name="RelationLastName" type="xs:string" minOccurs="0"/>
<xs:element name="Gender" type="xs:string" minOccurs="0"/>
<xs:element name="Age" type="xs:short" minOccurs="0"/>
<xs:element name="HouseNo" type="xs:string" minOccurs="0"/>
<xs:element name="ENO" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<No>120</No>
<AcName>fasf</AcName>
<PartNo>105</PartNo>
<Station>
xsdfsa
</Station>
<SlNo>489</SlNo>
<SectionName>2-</SectionName>
<FistName>Balachandra</FistName>
<LastName>Kalkur</LastName>
<RelationFirstName>Ti.Keshav Kalkur</RelationFirstName>
<RelationLastName/>
<Gender>M</Gender>
<Age>46</Age>
<HouseNo>3-57</HouseNo>
<ENO>adcv</ENO>
</Table>
</NewDataSet>
</diffgr:diffgram>
</DataSet>

code i am using to read 

            using (WebResponse Serviceres = request.GetResponse())
            {
                using (StreamReader rd = new StreamReader(Serviceres.GetResponseStream()))
                {
                    //reading stream  
                    var ServiceResult = rd.ReadToEnd();
                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml(ServiceResult);
                    //  XmlNodeList xNodelst = xml.DocumentElement.SelectNodes("/DataSet/NewDataSet/Table");//reading node so that we can traverse thorugh the XML
                    // XmlNodeList XList = xml.SelectNodes("//*");
                    XmlNodeList xnList = xml.SelectNodes("/NewDataSet/Table");
                }
            }

But i am not getting nodes. How to read data from above response.

This question does not have replies that have been liked.