anthonycaiozzo
New Member
I am having two different xml doxument which i am getting from webservice. By submitting first request i am getting the xml which containing the basic information of a hotel and having the structure like this\[code\]<offers><offer> <city_id>5</city_id> <city>Barcelona</city> <name>EnGrande test hotel</name> <address>Calle Muntaner 262</address> <price_no_vat>80</price_no_vat> <currency>EUR</currency> <type>Hotel</type> <description> A fantastic hotel at a fantastic price in a fantastic location. </description> <image_url>http://www.somesite.com/photos/hotels/bcn30_accomodation_1220_1.jpg</image_url> <offer_url>http://www.somesite.com/eg_offer_detail.php?hotel_id=191&checkin=2009-05-01&checkout=2009-05-02&city_id=5&guests=2</offer_url> <distance>3.175</distance></offer>\[/code\]and the second xml document which containing the detail of the hotels and having structure like this\[code\]<hotels><hotel> <hotel_id>191</hotel_id> <name>Test hotel</name> <type>hostel</type> <category>2</category> <street>C/ de la Victoria, 2 - 4th floor left door. Madrid 28012.</street> <postcode>28012</postcode> <city>Madrid</city> <city_id>5</city_id> <description>This is a fantastic hotel</description> <url>http://www.somesite.com/madrid-hostel-191-test-hotel.html</url> <pppn>27.10</pppn> <currency>EUR</currency> <longitude>-3.701687097549</longitude> <latitude>40.416587829590</latitude> <images> <image>http://www.somesite.com/photos/hotels/30mad_accomodation_5_1.jpg</image> <image>http://www.somesite.com/photos/hotels/30mad_accomodation_5_2.jpg</image> <image>http://www.somesite.com/photos/hotels/30mad_accomodation_5_3.jpg</image> <image>http://www.somesite.com/photos/hotels/30mad_accomodation_5_4.jpg</image> <image>http://www.somesite.com/photos/hotels/30mad_accomodation_5_5.jpg</image> <image>http://www.somesite.com/photos/hotels/30mad_accomodation_5_6.jpg</image> <image>http://www.somesite.com/photos/hotels/30mad_accomodation_5_7.jpg</image> <image>http://www.somesite.com/photos/hotels/30mad_accomodation_5_8.jpg</image> <image>http://www.somesite.com/photos/hotels/30mad_accomodation_5_9.jpg</image> </images> <amenities> <amenity>Elevator / lift</amenity> <amenity>Laundry / washing machine</amenity> <amenity>TV lounge</amenity> <amenity>Left-luggage office</amenity> <amenity>Reception available</amenity> <amenity>24h reception</amenity> <amenity>Credit cards accepted</amenity> <amenity>TV</amenity> <amenity>Telephone</amenity> <amenity>Fans</amenity> <amenity>Heating</amenity> <amenity>Hair dryer</amenity> <amenity>Towels & sheets</amenity> </amenities></hotel> \[/code\]now the second xml document contains many hotels of the same city. I want to search the hotel with its name in second xml document and display its details. I have create a php code for this which is look like this\[code\]<?php $city_id = 6;$request = "http://www.somewebsite.com/feeds/phpfile.php?vendor_key=xxx&checkin=26-11-2012&checkout=30-11-2012&guests=3&city_id=".$city_id;$same_city_hotels_request = "http://www.somewebsite.com/feeds/get-hotels.php?vendor_key=xxx&city_id=".$city_id; $offerxml = simplexml_load_file($request);$same_city = simplexml_load_file($same_city_hotels_request);$hotel = $offerxml->offer;for($i=0;$i<=10;$i++){ $hotel_info = $same_city->xpath("//hotel/name[contains(text(),'".$hotel[$i]->name."')]");{?><tr><td>name</td><td>category</td><td>city</td><td>Address</td><td>price</td><td>Image</td></tr><tr><td> <?php echo $hotel[$i]->name; ?></td><td><?php echo $hotel_info[$i]->category; ?></td><td> <?php echo $hotel[$i]->city; ?> </td><td><?php echo $hotel[$i]->address; ?></td><td><?php echo $hotel[$i]->price; ?></td><td><?php echo $hotel_info[$i]->image; ?></td></tr><?php } ?>\[/code\]can any body tell me what i am doing wrong here?