XML problem

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

The trick is to look at what is being returned. i.e.

stdClass Object ( [HotelsSearchResult] => stdClass Object ( [any] =>

Your code is assigning this object to the $result variable. So if you want to get the string that’s the value of “any” use object syntax to “drill down” to it.

Try adding this after your print_r($result); line

var_dump($result->HotelsSearchResult->any);

Then look in view-source.

Really Really thanks for your help… you solved a problem that faced me from 1 month

Really Thanks for your help

<?
// 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);

?>

Really thnx for ur help

waiting ur reply

No problem. The easiest would be for you to post the code you’re using now and having trouble with. Probably only a minor syntax change is needed.

Maybe you missed my reply in your other thread or you didn’t understand it?

It might help if you think of how it would look if it was an array. i.e.

$result[‘HotelsSearchResult’][‘any’] = "<xml …

Except for objects (like simplexml) you use “->”

So whatever the variable is for that object, the XML is

$your_object_name->HotelsSearchResult->any

and would be

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

Really thanks for your help but for reality…

[B]i did not understand what do you mean? and how to write my code???

could you please explain more???[/B]