PDA

View Full Version : xml problem


john_zakaria
06-16-2010, 09:40 AM
i am using a web service and test it in the web site http://www.soapclient.com/soaptest.html

and it return the result in XML format.

i made my own code in php but my problem is that i get the result in this format


stdClass Object
(
[HotelsSearchResult] => stdClass Object
(
[any] => <dsHotelSearchReturn xmlns="http://tempuri.org/dsHotelSearchReturn.xsd"><xs:schema xmlns:mstns="http://tempuri.org/dsHotelSearchReturn.xsd" xmlns="http://tempuri.org/dsHotelSearchReturn.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="dsHotelSearchReturn" targetNamespace="http://tempuri.org/dsHotelSearchReturn.xsd" attributeFormDefault="qualified" elementFormDefault="qualified"><xs:element name="dsHotelSearchReturn" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="Hotels"><xs:complexType><xs:sequence><xs:element name="HotelID" type="xs:int" minOccurs="0"/><xs:element name="RoomTypeID" type="xs:int" minOccurs="0"/><xs:element name="RoomSerial" type="xs:int" minOccurs="0"/><xs:element name="DateFrom" type="xs:dateTime" minOccurs="0"/><xs:element name="DateTo" type="xs:dateTime" minOccurs="0"/><xs:element name="Price" type="xs:decimal" minOccurs="0"/></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><Hotels><HotelID>243</HotelID><RoomTypeID>102</RoomTypeID><RoomSerial>2</RoomSerial><DateFrom>2010-06-12T00:00:00+02:00</DateFrom><DateTo>2010-06-13T00:00:00+02:00</DateTo><Price>90.00</Price></Hotels><Hotels><HotelID>7176</HotelID><RoomTypeID>125</RoomTypeID><RoomSerial>1</RoomSerial><DateFrom>2010-06-12T00:00:00+02:00</DateFrom><DateTo>2010-06-13T00:00:00+02:00</DateTo><Price>300.00</Price></Hotels><Hotels><HotelID>7176</HotelID><RoomTypeID>126</RoomTypeID><RoomSerial>2</RoomSerial><DateFrom>2010-06-12T00:00:00+02:00</DateFrom><DateTo>2010-06-13T00:00:00+02:00</DateTo><Price>360.00</Price></Hotels></dsHotelSearchReturn>

)

)




i want to transform 9it into xml format or to get the results of Hotels Data

Any help

Dormilich
06-16-2010, 12:27 PM
something like that?
$xml = $obj->HotelsSearchResult->any;

john_zakaria
06-16-2010, 12:42 PM
something like that?
$xml = $obj->HotelsSearchResult->any;
here it is my code please feed me back coz i must solve this problem today :(


<?
// display document in browser as plain text
// for readability purposes
header("Content-Type: text/plain");
// Call the Cdyne result Service. Debugging mode enabled (e.g. 'trace'=>true)
$client = new SOAPClient('http://196.218.16.133/OnlineReservationTravelline/service.asmx?WSDL');

try {
$params->HotelData = '<HotelsParameters><CityID>388</CityID><UserName>admin</UserName><UserPassword>admin</UserPassword><DateFrom>6/12/2010</DateFrom><DateTo>6/13/2010</DateTo><NumberOfRooms>2</NumberOfRooms><Room><RoomSerial>1</RoomSerial><Adults>1</Adults><Child><ChildSerial>1</ChildSerial><ChildAge>5</ChildAge></Child></Room><Room><RoomSerial>2</RoomSerial><Adults>2</Adults><Child><ChildSerial>1</ChildSerial><ChildAge>8</ChildAge></Child><Child><ChildSerial>2</ChildSerial><ChildAge>5</ChildAge></Child></Room><CurrencyID>162</CurrencyID></HotelsParameters>'; // set up parameters to pass. If we need multiple
// parameters, we can add additional elements to
// the array: $params->City = 'Dublin'

$result = $client->HotelsSearch($params);
//echo $result;
} catch (SOAPFault $exception) {
// if we hit an error, print the exception and the XML we sent
print $exception;
print htmlspecialchars($client->__getLastRequest());
// exit;
}

print_r($result);

?>

Dormilich
06-16-2010, 02:40 PM
$xml_string = $result->HotelsSearchResult->any;
$xml_doc = new DOMDocument;
$xml_doc->loadXML($xml_string);