How can i query multiple XPATH queries in the same while loop?
I have :
$dom = new DOMDocument();
$xpath = new DOMXPath($dom);
$reader = new XMLReader();
$reader->open($xmlurl);
while ($reader->read()) {
if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'Hotel') {
$node = $dom->importNode($reader->expand(), true);
$dom->appendChild($node);
$img1= $xpath->evaluate('string(self::Hotel[HotelCode = "'.$hotelCodes[1].'"]/HotelImages/ImageURL[1])', $node);
$dom->removeChild($node);
if ($img1) {
break; }
}
}
The above code parsing and query date based on a give variable $hotelCodes[x] It is posible to run multiple queries in the above code if they have a different variable as condition (for example to query the ImageURL ehere $hotelCodes[1] is found as HotelCode )
I need to pull several ImageURL`s for several hotelCodes, but i dont want to create a code for each query as it is slowing down my page alot.
No comments:
Post a Comment