Jump to content


This topic is now archived and is closed to further replies.


Parse XML dataset returned from .NET web service

Recommended Posts


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">

Share this post

Link to post
Share on other sites
See [a href=\"http://www.php.net/simplexml_load_file\" target=\"_blank\"]simplexml_load_file()[/a]


[code]    $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();[/code]

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.