Jump to content


Parse XML dataset returned from .NET web service

  • Please log in to reply
1 reply to this topic

#1 kiwikev

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 11 June 2006 - 12:40 PM


I'm trying to find a answer to the following, have been trying google but I must be missing something basic as I just cant seem to find the answer (my PHP skills are a bit outdated). I have developed a webservice in .NET ASP 2.0 that returns a dataset (example below). I need to be able to provide a PHP code snipit to another developer so they can call it and manipulate the data. I'm using PHP5 and the SoapClient with the service wsdl to call the service... how do I parse the returned dataset with its embedded XML schema into a object that I can simply loop through in PHP?

Thanks in advance...


Example of XML returned in result.

<?xml version="1.0" encoding="utf-8" ?>
<DataSet xmlns="http://ttt.co.nz/">
<xs:schema id="getQuoteExample" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="getQuoteExample" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="General">
<xs:element name="Status" type="xs:int" minOccurs="0" />
<xs:element name="StatusDOB" type="xs:int" minOccurs="0" />
<xs:element name="StatusGender" type="xs:int" minOccurs="0" />
<xs:element name="StatusSmoker" type="xs:int" minOccurs="0" />
<xs:element name="Age" type="xs:int" minOccurs="0" />
<xs:element name="QuoteExampleText" type="xs:string" minOccurs="0" />
<xs:element name="Examples">
<xs:element name="Term" type="xs:int" minOccurs="0" />
<xs:element name="Premium" type="xs:decimal" minOccurs="0" />
<xs:element name="Cover" type="xs:decimal" minOccurs="0" />
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<getQuoteExample xmlns="">
<General diffgr:id="General1" msdata:rowOrder="0">
<QuoteExampleText />
<Examples diffgr:id="Examples1" msdata:rowOrder="0">
<Examples diffgr:id="Examples2" msdata:rowOrder="1">
<Examples diffgr:id="Examples3" msdata:rowOrder="2">
<Examples diffgr:id="Examples4" msdata:rowOrder="3">
<Examples diffgr:id="Examples5" msdata:rowOrder="4">

#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 11 June 2006 - 12:50 PM

See [a href=\"http://www.php.net/simplexml_load_file\" target=\"_blank\"]simplexml_load_file()[/a]


    $xml = simplexml_load_file('http://www.domain.com/yourfile.php');
    $xsl = simpleXML_load_file('myformat.xsl');
    $proc = new XsltProcessor();
    $newxml = $proc->transformToDoc($xml);
    print $newxml->saveXML();

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users