hi, ihave somme deffecult with XML interpretation, as you can see my error code is
Fatal error: Uncaught exception ‘Exception’ with message ‘String could not be parsed as XML’ in C:.. SimpleXMLElement->__construct(‘’) #1 {main} thrown in C:…; when i tried to read child from xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="http://ericsson.com/services/ws_cma3/contractssearch">
<soapenv:Header/>
<soapenv:Body>
<con:contractsSearchResponse>
<!--You may enter the following 2 items in any order-->
<!--Optional:-->
<con:contracts>
<!--Zero or more repetitions:-->
<con:item>
<!--You may enter the following 39 items in any order-->
<!--Optional:-->
<con:contractTypeId>fysal</con:contractTypeId>
<!--Optional:-->
<con:foreignPlcode>123</con:foreignPlcode>
<!--Optional:-->
<con:homeBidGroupId>?</con:homeBidGroupId>
<!--Optional:-->
<con:foreignBidGroupId>?</con:foreignBidGroupId>
<!--Optional:-->
<con:coLec>?</con:coLec>
<!--Optional:-->
<con:buId>?</con:buId>
<!--Optional:-->
<con:coStatus>?</con:coStatus>
<!--Optional:-->
<con:csCode>?</con:csCode>
<!--Optional:-->
<con:dirnum>?</con:dirnum>
<!--Optional:-->
<con:dirnumBlocks>
<!--Zero or more repetitions:-->
<con:item>
<!--You may enter the following 2 items in any order-->
<!--Optional:-->
<con:lowerExt>?</con:lowerExt>
<!--Optional:-->
<con:upperExt>?</con:upperExt>
</con:item>
</con:dirnumBlocks>
<!--Optional:-->
<con:adrFname>?</con:adrFname>
<!--Optional:-->
<con:adrLname>?</con:adrLname>
<!--Optional:-->
<con:adrName>?</con:adrName>
<!--Optional:-->
<con:adrStreet>?</con:adrStreet>
<!--Optional:-->
<con:adrStreetno>?</con:adrStreetno>
<con:markedForRerating>?</con:markedForRerating>
<!--Optional:-->
<con:csDealerid>?</con:csDealerid>
<!--Optional:-->
<con:sharedBusinessStartDate>?</con:sharedBusinessStartDate>
<!--Optional:-->
<con:sharedBusinessExpirationDate>?</con:sharedBusinessExpirationDate>
</con:item>
</con:contracts>
<!--Optional:-->
<con:searchIsComplete>?</con:searchIsComplete>
</con:contractsSearchResponse>
</soapenv:Body>
</soapenv:Envelope>
Fatal error: Call to a member function registerXPathNamespace() on a non-object in C:\EasyPHP 2.0b1\www\New_proget_finale_ayoub\webservice4glamya\testayoub\tesd.php on line 65
this is my update code suche as what you say to me:
echo $soapClient->__getLastRequest();
var_dump ($reponse);
$reponse= $soapClient->__getLastResponse();
$xml = simplexml_load_string($reponse);
print_r($xml);
/* Search for
*/
$xml->registerXPathNamespace(‘s’, ‘http://schemas.xmlsoap.org/soap/envelope/’);
$xml->registerXPathNamespace(‘c’, ‘http://ericsson.com/services/ws_cma3/contractssearch’);
$result = $xml->xpath(‘//s:Body/c:contractsSearchResponse/c:contracts/c:item’);
while(list( , $node) = each($result))
{
echo '/contractsSearchResponse/contracts/item/contractTypeId: ',$node,“\n”;
}
I have any result result, purhaps this probleme is due to children of item node(and tehre are 2 same item node) see these lines
<con:item>
<!--You may enter the following 39 items in any order-->
<!--Optional:-->
<con:contracttypeid>fysal</con:contracttypeid>
<!--Optional:-->
<con:foreignplcode>123</con:foreignplcode>
<!--Optional:-->
<con:homebidgroupid>?</con:homebidgroupid>
<!--Optional:-->
<con:foreignbidgroupid>?</con:foreignbidgroupid>
<!--Optional:-->
<con:colec>?</con:colec>
<!--Optional:-->
<con:buid>?</con:buid>
<!--Optional:-->
<con:costatus>?</con:costatus>
<!--Optional:-->
<con:cscode>?</con:cscode>
<!--Optional:-->
<con:dirnum>?</con:dirnum>
<!--Optional:-->
<con:dirnumblocks>
<!--Zero or more repetitions:-->
<con:item>
<!--You may enter the following 2 items in any order-->
<!--Optional:-->
<con:lowerext>?</con:lowerext>
<!--Optional:-->
<con:upperext>?</con:upperext>
</con:item>
</con:dirnumblocks>
Yes, as I said, once you’ve found the item nodes with the xpath query, you’d need to iterate over the child nodes within each ‘item’ to collect the data that you want from that item.