On Friday 26 October 2007 01:06, Jamesas wrote: > i am new to soap and xml > > i am get http://www.nabble.com/file/p13407919/works.php works.php ting soap > response like the following and i use the code like this but is too hard > to read the xml format. > I need hotel name and hotel detail from it. > > $xmlstr=simplexml_load_string($res); > echo > $xmlstr->SearchHotelsResponse->SearchHotelsResult->TWS_HotelList->Hotel[hot >elId]; > > it does not return any result. > > plz help me to work in php 5 I have managed to retrieve the data from the XML. I am sure you can manage to get the right data you want from the data array which is produced. /** * utility function for making print_r prettier */ function print_r_pre($data) { echo "<pre>"; print_r($data); echo "</pre>"; } $xml = new SimpleXMLElement($soap_response_string, NULL, false, 'http://schemas.xmlsoap.org/soap/envelope/'); if ($xml instanceof SimpleXMLElement) { $ns = $xml->getNamespaces(true); print_r_pre($ns); foreach ($ns as $namespace) { foreach ($xml->children($namespace) as $node) { $children = $node->xpath('child::node()'); echo "Count of children: " . count($children) . "<br />"; print_r_pre($children); } $xml = $node; } } You need to read up on XML and namespaces to better understand how the data is retrieved. cheers, Jeffery > > > > The response is follows: > > > > <?xml version="1.0" encoding="utf-8" ?> > - <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > - <soap:Body> > - <SearchHotelsResponse xmlns="http://tourico.com/webservices/"> > - <SearchHotelsResult> > - <xs:schema id="TWS_HotelList" > targetNamespace="http://tourico.com/webservices/TWS_HotelList.xsd" > xmlns:mstns="http://tourico.com/webservices/TWS_HotelList.xsd" > xmlns="http://tourico.com/webservices/TWS_HotelList.xsd" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" > xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" > attributeFormDefault="qualified" elementFormDefault="qualified"> > - <xs:element name="TWS_HotelList" msdata:IsDataSet="true" > msdata:Locale="en-US"> > - <xs:complexType> > - <xs:choice minOccurs="0" maxOccurs="unbounded"> > - <xs:element name="Hotel"> > - <xs:complexType> > - <xs:sequence> > - <xs:element name="RoomType" minOccurs="0" maxOccurs="unbounded"> > - <xs:complexType> > - <xs:sequence> > - <xs:element name="Avail" minOccurs="0" maxOccurs="unbounded"> > - <xs:complexType> > <xs:attribute name="offset" form="unqualified" type="xs:byte" > use="required" /> > <xs:attribute name="status" form="unqualified" type="xs:boolean" > use="required" /> > </xs:complexType> > </xs:element> > - <xs:element name="Discount" minOccurs="0" maxOccurs="unbounded"> > - <xs:complexType> > <xs:attribute name="from" form="unqualified" type="xs:dateTime" > use="required" /> > <xs:attribute name="to" form="unqualified" type="xs:dateTime" > use="required" /> > <xs:attribute name="pay" form="unqualified" type="xs:int" use="required" > /> > <xs:attribute name="stay" form="unqualified" type="xs:int" use="required" > /> > </xs:complexType> > </xs:element> > - <xs:element name="Occup" minOccurs="0" maxOccurs="unbounded"> > - <xs:complexType> > - <xs:sequence> > - <xs:element name="Supp" minOccurs="0" maxOccurs="unbounded"> > - <xs:complexType> > <xs:attribute name="supId" form="unqualified" type="xs:int" /> > <xs:attribute name="name" form="unqualified" type="xs:string" > use="required" /> > <xs:attribute name="price" form="unqualified" type="xs:double" > use="required" /> > </xs:complexType> > </xs:element> > - <xs:element name="Board" minOccurs="0" maxOccurs="unbounded"> > - <xs:complexType> > <xs:attribute name="bbId" form="unqualified" type="xs:int" /> > <xs:attribute name="name" form="unqualified" type="xs:string" > use="required" /> > <xs:attribute name="price" form="unqualified" type="xs:double" > use="required" /> > <xs:attribute name="default" form="unqualified" > msprop:Generator_UserColumnName="default" > msprop:Generator_ColumnVarNameInTable="column_default" > msprop:Generator_ColumnPropNameInRow="_default" > msprop:Generator_ColumnPropNameInTable="_defaultColumn" type="xs:boolean" > default="false" /> > </xs:complexType> > </xs:element> > - <xs:element name="Room" minOccurs="0" maxOccurs="unbounded"> > - <xs:complexType> > - <xs:sequence> > - <xs:element name="Child" minOccurs="0" maxOccurs="unbounded"> > - <xs:complexType> > <xs:attribute name="age" form="unqualified" type="xs:int" /> > </xs:complexType> > </xs:element> > </xs:sequence> > <xs:attribute name="seqNum" form="unqualified" type="xs:int" > use="required" /> > <xs:attribute name="adultNum" form="unqualified" type="xs:int" > use="required" /> > <xs:attribute name="childNum" form="unqualified" type="xs:int" /> > </xs:complexType> > </xs:element> > - <xs:element name="Price" minOccurs="0" maxOccurs="unbounded"> > - <xs:complexType> > <xs:attribute name="offset" form="unqualified" type="xs:int" > use="required" /> > <xs:attribute name="value" form="unqualified" type="xs:double" > use="required" /> > </xs:complexType> > </xs:element> > </xs:sequence> > <xs:attribute name="occupId" form="unqualified" type="xs:string" > use="required" /> > <xs:attribute name="maxAdult" form="unqualified" type="xs:int" > use="required" /> > <xs:attribute name="maxChild" form="unqualified" type="xs:int" > use="required" /> > <xs:attribute name="price" form="unqualified" type="xs:double" > use="required" /> > <xs:attribute name="tax" form="unqualified" type="xs:double" > use="required" /> > <xs:attribute name="dblBed" form="unqualified" type="xs:boolean" /> > <xs:attribute name="avrNightPrice" form="unqualified" type="xs:double" > use="required" /> > </xs:complexType> > </xs:element> > </xs:sequence> > <xs:attribute name="productId" form="unqualified" type="xs:string" > use="required" /> > <xs:attribute name="name" form="unqualified" type="xs:string" > use="required" /> > <xs:attribute name="nights" form="unqualified" type="xs:byte" > use="required" /> > <xs:attribute name="startDate" form="unqualified" type="xs:dateTime" > use="required" /> > <xs:attribute name="isAvailable" form="unqualified" type="xs:boolean" /> > <xs:attribute name="roomId" form="unqualified" type="xs:int" /> > <xs:attribute name="hotelRoomTypeId" form="unqualified" type="xs:int" /> > </xs:complexType> > </xs:element> > </xs:sequence> > <xs:attribute name="hotelId" form="unqualified" type="xs:int" > use="required" /> > <xs:attribute name="provider" form="unqualified" type="xs:string" > use="required" /> > <xs:attribute name="name" form="unqualified" type="xs:string" > use="required" /> > <xs:attribute name="address" form="unqualified" type="xs:string" /> > <xs:attribute name="category" form="unqualified" type="xs:string" /> > <xs:attribute name="bestVal" form="unqualified" type="xs:byte" /> > <xs:attribute name="thumb" form="unqualified" type="xs:string" /> > <xs:attribute name="starsLevel" form="unqualified" type="xs:double" /> > <xs:attribute name="minAverPrice" form="unqualified" type="xs:double" > use="required" /> > <xs:attribute name="desc" form="unqualified" type="xs:string" > use="required" /> > <xs:attribute name="location" form="unqualified" type="xs:string" > use="required" /> > <xs:attribute name="currency" form="unqualified" type="xs:string" /> > <xs:attribute name="brandId" form="unqualified" type="xs:int" /> > <xs:attribute name="brandName" form="unqualified" type="xs:string" /> > </xs:complexType> > </xs:element> > </xs:choice> > </xs:complexType> > </xs:element> > </xs:schema> > - <TWS_HotelList xmlns="http://tourico.com/webservices/TWS_HotelList.xsd"> > - <Hotel hotelId="8863" provider="localTgsProvider" name="Crowne Plaza JFK > Airport - DEMO" address="DEMO - 151-20 Baisley Boulevard New York New York > 11434" category="Moderate" bestVal="0" > thumb="http://image1.urlforimages.com/8863/CrownePlazaJFK-Front_Thumbnailed >.jpg" starsLevel="3" minAverPrice="315.34" desc="DEMO - This premier > business hotel, with easy access to the airport, is not far from the hustle > and bustle of Manhattan, where you can visit Times Square, Rockefeller > Center, Macy's or the Metropolitan Museum of Art just to name a few > possibilities." location="JFK International Airport Area,New York,NY,US" > currency="USD" brandId="140" brandName="Crowne Plaza Hotels"> > - <RoomType productId="8863;6803;6321" name="Standard" nights="11" > startDate="2007-11-20T00:00:00-05:00" isAvailable="true" roomId="3" > hotelRoomTypeId="6803"> > <Avail offset="0" status="true" /> > <Avail offset="1" status="true" /> > <Avail offset="2" status="true" /> > <Avail offset="3" status="true" /> > <Avail offset="4" status="true" /> > <Avail offset="5" status="true" /> > <Avail offset="6" status="true" /> > <Avail offset="7" status="true" /> > <Avail offset="8" status="true" /> > <Avail offset="9" status="true" /> > <Avail offset="10" status="true" /> > - <Occup occupId="8863;6803;6321;2;2;0;1" maxAdult="4" maxChild="2" > price="3468.7" tax="467.83" dblBed="true" avrNightPrice="315.34"> > - <Room seqNum="1" adultNum="1" childNum="1"> > <Child age="8" /> > </Room> > <Price offset="0" value="297.55" /> > <Price offset="1" value="297.55" /> > <Price offset="2" value="297.55" /> > <Price offset="3" value="297.55" /> > <Price offset="4" value="297.55" /> > <Price offset="5" value="297.55" /> > <Price offset="6" value="336.68" /> > <Price offset="7" value="336.68" /> > <Price offset="8" value="336.68" /> > <Price offset="9" value="336.68" /> > <Price offset="10" value="336.68" /> > </Occup> > </RoomType> > </Hotel> > - <Hotel hotelId="3297" provider="localTgsProvider" name="Paramount Hotel - > DEMO" address="DEMO - 235 W 46th St New York New York 10036" > category="First Class" bestVal="1" > thumb="http://image1.urlforimages.com/3297/Paramount-exterior_Thumbnailed.j >pg" starsLevel="3.5" minAverPrice="368.74" desc="DEMO - The trendsetting > Paramount is an Art Nouveau hotel designed by Philippe Starck. It's just > less than a block from Broadway and Times Square and a short distance from > great shopping on Fifth Avenue and the famous Rockefeller Center." > location="Manhattan - Times Square/Broadway,New York,NY,US" currency="USD" > brandId="0" brandName=""> > - <RoomType productId="3297;1426;1426" name="Standard" nights="11" > startDate="2007-11-20T00:00:00-05:00" isAvailable="true" roomId="3" > hotelRoomTypeId="1426"> > <Avail offset="0" status="true" /> > <Avail offset="1" status="true" /> > <Avail offset="2" status="true" /> > <Avail offset="3" status="true" /> > <Avail offset="4" status="true" /> > <Avail offset="5" status="true" /> > <Avail offset="6" status="true" /> > <Avail offset="7" status="true" /> > <Avail offset="8" status="true" /> > <Avail offset="9" status="true" /> > <Avail offset="10" status="true" /> > - <Occup occupId="3297;1426;1426;3;2;0" maxAdult="2" maxChild="0" > price="4056.16" tax="520.09" dblBed="true" avrNightPrice="368.74"> > - <Room seqNum="1" adultNum="1" childNum="1"> > <Child age="8" /> > </Room> > <Price offset="0" value="252.68" /> > <Price offset="1" value="252.68" /> > <Price offset="2" value="252.68" /> > <Price offset="3" value="335.94" /> > <Price offset="4" value="335.94" /> > <Price offset="5" value="335.94" /> > <Price offset="6" value="446.96" /> > <Price offset="7" value="446.96" /> > <Price offset="8" value="446.96" /> > <Price offset="9" value="474.71" /> > <Price offset="10" value="474.71" /> > </Occup> > </RoomType> > </Hotel> > </TWS_HotelList> > </SearchHotelsResult> > </SearchHotelsResponse> > </soap:Body> > </soap:Envelope> > -- > View this message in context: > http://www.nabble.com/problem-in-reading-soap-response.-tf4691230.html#a134 >07919 Sent from the Php - Soap mailing list archive at Nabble.com. -- Internet Vision Technologies Level 1, 520 Dorset Road Croydon Victoria - 3136 Australia
Attachment:
pgpjgZHDtjd91.pgp
Description: PGP signature