Sreeram Posted March 22, 2013 Share Posted March 22, 2013 Recently i have started Flight portal website. In that for displaying the details of flight like availability, cancellation , fare , etc.. i am sending a SOAP XML request in php the code is as below <?php $xml_data="<arzHotelAvailReq><clientInfo> <username>UdooInXML</username> <userType>ArzooHWS1.1</userType> <userID>77743543</userID> <password>*CB8</password> <partnerID>1002</partnerID> </clientInfo> <requestSegment> <currency>INR</currency> <searchType>search</searchType> <residentOfIndia>true</residentOfIndia> <stayDateRange> <start>22/03/2013</start> <end>23/03/2013</end> </stayDateRange> <roomStayCandidate> <guestDetails> <adults>1</adults> <child> <age>3</age> <age>5</age> </child> </guestDetails> <guestDetails> <adults>2</adults> <child> <age>2</age> </child> </guestDetails> </roomStayCandidate> <hotelSearchCriteria> <hotelCityName>BANGALORE</hotelCityName> <hotelName></hotelName> <area></area> <attraction></attraction> <rating></rating> <sortingPreference>1 </sortingPreference> <hotelPackage>Y</hotelPackage></hotelSearchCriteria></requestSegment></arzHotelAvailReq> "; Here the soap client request code comes. and i am getting the response. Everything is fine upto here. But i am getting the response in a irregular text format like as below. 100200 INR search 22/03/2013 23/03/2013 1 3 5 2 2 BANGALORE 1 Y true 00005380 Veekay Tourist Home Overlooking the beautiful park, this homely abode is close to the ISKON Temple. Across three floors are 80 AC and non-AC rooms, which are maintained with room service. Guests can experience the essence of the city with a tour, which is organized by the home on demand. There is free parking facility provided to the guests to park their vehicles. 1 2 400 033 arzooB 91/1, Railway Parallel Road Yeshwantpur NA Overlooking the beautiful park, this homely abode is close to the ISKON Temple. Across three floors are 80 AC and non-AC rooms, which are maintained with room service. Guests can experience the essence of the city with a tour, which is organized by the home on demand. There is free parking facility provided to the guests to park their vehicles. NA NA NA NA 00:00 12:00 All NA NA Air_Conditioning,Restaurant,Conference_Hall,Health_Club,Travel_Desk,Transfers,Forex,Shopping,Swimming,Banquet,Business_Center NA cdn.travelpartnerweb.com/DesiyaImages/Image/1/nxd/maw/ryj/lbn/HO_TN.jpg N N Non AC Room No Amenities 0000019527 0000068265 11111111 +yWrLQerwfpRqCOBdo4d4Q+fTZgh1nupLJ4p4u6ke0DnoKrM1YnV+CyeKeLupHtAek/xho0eiejEOsNqkniCrj61Dp4lgPVpxhyWcxAZvAY6eaST9cxEwO77vKeHzGt7xDrDapJ4gq4OONbvuHIwesuQNW1tG3pMLXm9B6RXzcuVQyNiR9Nkmc5UwHnlMe/3R4pOa9nZpzWvpc4Pgi4QldI0kqzTn0R2SrrkswfU4tEe+FrLnNX0ikMr6KYsRwZ5weOUbgjswoE6Gc2xDYzFhoJPdnFEgTGV53WGRs0ArO3XjoptM/3++Ebal1NQKw41+CLkev7bTS2uy9dZCeYpxW/ouG38h9xmYh+h8WdKEfuf5HK8TIYqr3cMt7sdhfmbFluz6IhIkl5gGOFLUgob5fJgMkJc5m29X6/0s/8xt7Kj8slKZijCITtF+SlZboPr 84 751 0 0.0 0 N N AC Double No Amenities 0000019528 0000068266 11111111 MqJjfxbuxrY6eaST9cxEwDETzbfNeAOGmk9s1Uz6PbYSZIViwgQiY5pPbNVM+j22FHM8WEydgwBkOaDlTL6ZjC9zLGtHv0ypOnmkk/XMRMAPn02YIdZ7qUC2Sm/k4OAAweOUbgjswoF0RTNIMdh6k+Ld9K5fVWUdDznXXQXDz4XzARG+d1YhoTBLNxtfNxqmAcSIgU/v1x3EOsNqkniCrr6b1Ug4ytFJZ/0FayiZJBkPeiwpn9EJwEbIPnPEbTR4lWhM0grn0WLZ56unmN2SYl3cbsmEPmwq2OuHVC1F8Hu84Nfh1MF/h4/ba1HimMaE+uDhm6Ks2qonJVGPUcpVXdQrEjcaz9CVv8aChDAx1MrEOsNqkniCrtPU6ffG6Zo+VJRf6bY5MD9Jpvu9wmltGrCdLm1c957TFF2epIoxL54OaXRTmdyfd1yCAU1C72cA 0 1684 60 0.0 0 00005020 U.G.DELUXE Located near to the Srinivasa Nursing Home, this brand new smoke-free property on the block is maintained with 42 deluxe rooms, which includes A/C and non-A/C accommodations. There are three dining outlets, namely Malabar Vegetarian Restaurant, Krishna Bhavan, and Sukh Sagar, which are all open for service from 6a.m to 10p.m. The property is designed with a garden area, where guests can lounge. They can also avail the assistance of the travel desk and take a tour of the beautiful city. 0 2 550 061 arzooB #9/1, 2nd Cross,Thulasithotam Balepet Near Srinivasa Nursing Home NA Located near to the Srinivasa Nursing Home, this brand new smoke-free property on the block is maintained with 42 deluxe rooms, which includes A/C and non-A/C accommodations. There are three dining outlets, namely Malabar Vegetarian Restaurant, Krishna Bhavan, and Sukh Sagar, which are all open for service from 6a.m to 10p.m. The property is designed with a garden area, where guests can lounge. They can also avail the assistance of the travel desk and take a tour of the beautiful city. NA NA NA NA 00:00 12:00 All NA NA Air_Conditioning,Restaurant,Conference_Hall,Health_Club,Travel_Desk,Transfers,Forex,Shopping,Swimming,Banquet,Business_Center NA cdn.travelpartnerweb.com/DesiyaImages/Image/1/nxd/maw/rym/fbn/HO_TN.jpg N N Double Deluxe Non AC No Amenities 0000018167 0000058501 11111111 6rHbdJ5eYI7GHJZzEBm8BvOaNWWi+RUhLJ4p4u6ke0DPzHJ7gHRp3iyeKeLupHtAhduj3Vq+cinEOsNqkniCrj61Dp4lgPVpxhyWcxAZvAY6eaST9cxEwO77vKeHzGt7xDrDapJ4gq4OONbvuHIwepH1wYi4aVVmDxAoeeQIBeo7G/tKB6tJOYDfWwbV0F7ASAS/psz+s/vtFOZDhaz6EtGf96t/LsuWxw1Qqnbhmf3XYWyQ7VUjC8Q6w2qSeIKuoKFs0O+FVtNhRIfAcxLjf86bGU9wLBRNvD/Qlqcc//JzmIzIGoODhM1oJoq2rZMN1gD5nlU38lH0iT7gaoTgQlkLlahFGUKDXPHozEiWFpzUKxI3Gs/Qlb/GgoQwMdTKxDrDapJ4gq7T1On3xumaPlSUX+m2OTA/Sab7vcJpbRqwnS5tXPee0xRdnqSKMS+eDml0U5ncn3eFGMF7Jssn/w== 0 966 44 0.0 0 N N Double Deluxe AC No Amenities 0000018168 0000058502 11111111 sSCoszzZkH86eaST9cxEwDETzbfNeAOGmk9s1Uz6PbZGv/SG567OsZpPbNVM+j22DfbGKTDMXKFkOaDlTL6ZjC9zLGtHv0ypOnmkk/XMRMAPn02YIdZ7qUC2Sm/k4OAAweOUbgjswoF0RTNIMdh6kznLtLUAmNXdxBAFTfOqI33OVMB55THv90eKTmvZ2ac1r6XOD4IuEJXSNJKs059Edkq65LMH1OLRxhyWcxAZvAZDK+imLEcGecHjlG4I7MKBOhnNsQ2MxYZ+oLyPTZ3RMaAnkAotaRPKKfHYXniQp/S8zzpKPZaLArk7+CKaeLo9hOB8fqTxssT128imfeXuC/OgEXYIgsG2UHFvTjsO+sCf5HK8TIYqr+4vK3ryvrJwFluz6IhIkl4/hAHmlwnis6hroDhh/C42mx8+gs3lzQiWJgzCcdsB9fCEqLc7/4v1LJ4p4u6ke0CUdoTzsl6ZtBfc5EobFJGF 0 1318 60 0.0 0 00004788 U.G.ROYAL Strategically located near to the railway station by 2kms, this smoke-free property is designed with 3floors with an elevator, and maintained with 24 rooms to reside in. The property is also maintained with a garden space and a travel counter for all travel assistance. A vegetarian fare can be savoured in the nearby Sukh Sagar Restaurant and non-vegetarian fare can be relished in any of the neighboring dining outlets, namely New Grand and Hyderabad. 0 2 650 062 arzooB # 42, Cottonpet Main Road NA Strategically located near to the railway station by 2kms, this smoke-free property is designed with 3floors with an elevator, and maintained with 24 rooms to reside in. The property is also maintained with a garden space and a travel counter for all travel assistance. A vegetarian fare can be savoured in the nearby Sukh Sagar Restaurant and non-vegetarian fare can be relished in any of the neighboring dining outlets, namely New Grand and Hyderabad. NA NA NA NA 00:00 12:00 All NA NA Air_Conditioning,Restaurant,Conference_Hall,Health_Club,Travel_Desk,Transfers,Forex,Shopping,Swimming,Banquet,Business_Center NA cdn.travelpartnerweb.com/DesiyaImages/Image/1/nxd/maw/syf/lbv/HO_TN.jpg N N Double Deluxe Non AC No Amenities 0000017219 0000054610 11111111 oHS5Xd5Exyg6eaST9cxEwGZSjnNN3mhmmk9s1Uz6PbaNc1sEsAf/6JpPbNVM+j22if6NKX9Uk13Dy1lDA4noii9zLGtHv0ypOnmkk/XMRMAPn02YIdZ7qUC2Sm/k4OAAweOUbgjswoF0RTNIMdh6kznLtLUAmNXdU8J0wP+0TP07G/tKB6tJOYDfWwbV0F7ASAS/psz+s/vtFOZDhaz6EtGf96t/LsuWxw1Qqnbhmf3XYWyQ7VUjC8Q6w2qSeIKuoKFs0O+FVtN4j8rH+f6mNO5qfq4xpPlORexVeZq9N0yqKIuRorLprNQrEjcaz9CVv8aChDAx1MrEOsNqkniCrtPU6ffG6Zo+VJRf6bY5MD9Jpvu9wmltGrCdLm1c957TFF2epIoxL54OaXRTmdyfd0BBbtk2xLpA 0 1142 52 0.0 0 N N Deluxe Double AC No Amenities 0000017221 0000054612 11111111 TxbgXP3Nk6o6eaST9cxEwO0QCFlSnc8Cmk9s1Uz6PbaNc1sEsAf/6JpPbNVM+j22fMzm237c+vR3p+iuYvo+Ai9zLGtHv0ypOnmkk/XMRMAPn02YIdZ7qUC2Sm/k4OAAweOUbgjswoF0RTNIMdh6kznLtLUAmNXdU8J0wP+0TP07G/tKB6tJOYDfWwbV0F7ASAS/psz+s/vtFOZDhaz6EtGf96t/LsuWxw1Qqnbhmf3XYWyQ7VUjC8Q6w2qSeIKuoKFs0O+FVtN4j8rH+f6mNO5qfq4xpPlORexVeZq9N0yqKIuRorLprNQrEjcaz9CVv8aChDAx1MrEOsNqkniCrtPU6ffG6Zo+VJRf6bY5MD9Jpvu9wmltGrCdLm1c957TFF2epIoxL54OaXRTmdyfd4cJw1cUhwyo 0 1580 72 0.0 0 00004786 U.G.GRAND A large photo frame of Lord Venkatesh at the lobby welcomes guests to a comfortable stay in this four floors hotel located in the NP Lane. There are 16 rooms facilitated with 24hours room service. A vegetarian fare can be relished at the Krishna Sagar Delhi Restaurant, which is open for service from 6a.m. to 10a.m., and non-vegetarian fare can be savoured in the Hyderabad Biryani Restaurant, which can be visited between 10a.m. to 11p.m. There is free valet parking facility also available in this hotel. 0 2 650 108 arzooB NO.10,N.P. LANE,COTTON PET BEHIND SHANTALA SILKS So here i want to arrange that response in a designed format. How can i do that. Please give me your valuable suggestions. Thanks in advance, Sree ram Quote Link to comment Share on other sites More sharing options...
Barand Posted March 22, 2013 Share Posted March 22, 2013 You could create an XSLT stylesheet for the XML or process the XML yourself eg $xml = simplexml_load_string($xml_data); $req = $xml->requestSegment; echo "<table border='1' cellpadding='4'>\n"; echo "<tr><th>Currency</th><td colspan='2'>{$req->currency}</td></tr>"; echo "<tr><th>Search Type</th><td colspan='2'>{$req->searchType}</td></tr>"; echo "<tr><th rowspan='2'>Stay Dates</th><th>From</th><th>To</th></tr>"; echo "<tr><td>{$req->stayDateRange->start}</td><td>{$req->stayDateRange->end}</td></tr>"; foreach ($req->roomStayCandidate->guestDetails as $guest) { echo "<tr><th rowspan='2'>Guest</th><th>Adults</th><th>Child Ages</th></tr>"; echo "<tr><td>{$guest->adults}</td><td> "; foreach($guest->child->age as $age) echo $age . ' '; echo "</td></tr>"; } echo "</table>\n"; Quote Link to comment Share on other sites More sharing options...
requinix Posted March 22, 2013 Share Posted March 22, 2013 Barand, I think that is the request XML being sent, not the response XML. For that "irregular text", are you sure it's text and not XML? Do a View Source of the page. Quote Link to comment Share on other sites More sharing options...
Sreeram Posted March 23, 2013 Author Share Posted March 23, 2013 Hi friends, Thanks for your response. As i mentioned the first is for sending the request to server. I have a taken that code into a file XML.php and executed . Then i got that irregular response. Hello Barand i will try you procedure and let you know what happened. Hello requinix, I view source that irregular page and i got the xml code there. Quote Link to comment Share on other sites More sharing options...
Sreeram Posted March 23, 2013 Author Share Posted March 23, 2013 You could create an XSLT stylesheet for the XML or process the XML yourself eg $xml = simplexml_load_string($xml_data); $req = $xml->requestSegment; echo "<table border='1' cellpadding='4'>\n"; echo "<tr><th>Currency</th><td colspan='2'>{$req->currency}</td></tr>"; echo "<tr><th>Search Type</th><td colspan='2'>{$req->searchType}</td></tr>"; echo "<tr><th rowspan='2'>Stay Dates</th><th>From</th><th>To</th></tr>"; echo "<tr><td>{$req->stayDateRange->start}</td><td>{$req->stayDateRange->end}</td></tr>"; foreach ($req->roomStayCandidate->guestDetails as $guest) { echo "<tr><th rowspan='2'>Guest</th><th>Adults</th><th>Child Ages</th></tr>"; echo "<tr><td>{$guest->adults}</td><td> "; foreach($guest->child->age as $age) echo $age . ' '; echo "</td></tr>"; } echo "</table>\n"; Hello barand, I am new to this concept. I didnt understood your code. But i have tried the below code. <?php $xml_data=" <arzHotelAvailReq> <clientInfo> <username>UdooInXML</username> <userType>ArzooHWS1.1</userType> <userID>77</userID> <password>*</password> <partnerID>100200</partnerID> </clientInfo> <requestSegment> <currency>INR</currency> <searchType>search</searchType> <residentOfIndia>true</residentOfIndia> <stayDateRange> <start>24/03/2013</start> <end>25/03/2013</end> </stayDateRange> <roomStayCandidate> <guestDetails> <adults>1</adults> <child> <age>3</age> <age>5</age> </child> </guestDetails> <guestDetails> <adults>2</adults> <child> <age>2</age> </child> </guestDetails> </roomStayCandidate> <hotelSearchCriteria> <hotelCityName>BANGALORE</hotelCityName> <hotelName></hotelName> <area></area> <attraction></attraction> <rating></rating> <sortingPreference>1 </sortingPreference> <hotelPackage>Y</hotelPackage> </hotelSearchCriteria> </requestSegment> </arzHotelAvailReq> "; $info = 'Request to server comes here.' $sxe = new SimpleXMLElement($info); $result = $sxe->xpath('//hotelname'); foreach ($result as $hotelname) { echo $hotelname."="; } ?> so now i am getting all the hotel names like as below. Hotel 1 Hotel 2 Hotel 3 Hotel 4 upto here it is fine. But now this is working for only one variable. If i want the result like this Hotel = Rate Hotel 1 = 4000 Hotel 2 = 3000 Hotel 3 = 2500 Then what will be the code. Please Let me know.... Quote Link to comment Share on other sites More sharing options...
Barand Posted March 23, 2013 Share Posted March 23, 2013 I am new to this concept. I didnt understood your code. But i have tried the below code. If you ran my code you would get the output in the attached image. You should recognise the data as that in the "irregular text" you posted earlier and wanted formatting As for hotels, there are no names in the data, just empty name tags. <hotelSearchCriteria> <hotelCityName>BANGALORE</hotelCityName> <hotelName></hotelName> <area></area> <attraction></attraction> <rating></rating> <sortingPreference>1 </sortingPreference> <hotelPackage>Y</hotelPackage> </hotelSearchCriteria> Quote Link to comment 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.