kiwikev Posted June 11, 2006 Share Posted June 11, 2006 HiI'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...KExample 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:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="General"> <xs:complexType> <xs:sequence> <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:sequence> </xs:complexType> </xs:element> <xs:element name="Examples"> <xs:complexType> <xs:sequence> <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" /> </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"> <getQuoteExample xmlns=""> <General diffgr:id="General1" msdata:rowOrder="0"> <Status>0</Status> <StatusDOB>0</StatusDOB> <StatusGender>0</StatusGender> <StatusSmoker>0</StatusSmoker> <Age>35</Age> <QuoteExampleText /> </General> <Examples diffgr:id="Examples1" msdata:rowOrder="0"> <Term>1</Term> <Premium>9.99</Premium> <Cover>100000</Cover> </Examples> <Examples diffgr:id="Examples2" msdata:rowOrder="1"> <Term>5</Term> <Premium>19.99</Premium> <Cover>200000</Cover> </Examples> <Examples diffgr:id="Examples3" msdata:rowOrder="2"> <Term>10</Term> <Premium>29.99</Premium> <Cover>300000</Cover> </Examples> <Examples diffgr:id="Examples4" msdata:rowOrder="3"> <Term>15</Term> <Premium>39.99</Premium> <Cover>400000</Cover> </Examples> <Examples diffgr:id="Examples5" msdata:rowOrder="4"> <Term>20</Term> <Premium>49.99</Premium> <Cover>500000</Cover> </Examples> </getQuoteExample> </diffgr:diffgram></DataSet> Quote Link to comment https://forums.phpfreaks.com/topic/11705-parse-xml-dataset-returned-from-net-web-service/ Share on other sites More sharing options...
Barand Posted June 11, 2006 Share Posted June 11, 2006 See [a href=\"http://www.php.net/simplexml_load_file\" target=\"_blank\"]simplexml_load_file()[/a]eg[code] $xml = simplexml_load_file('http://www.domain.com/yourfile.php'); $xsl = simpleXML_load_file('myformat.xsl'); $proc = new XsltProcessor(); $proc->importStylesheet($xsl); $newxml = $proc->transformToDoc($xml); print $newxml->saveXML();[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11705-parse-xml-dataset-returned-from-net-web-service/#findComment-44252 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.