Results 1 to 9 of 9
Thread: Amend PHP with Xpath sorting
Apr 4, 2013, 03:13 #1
- Join Date
- Dec 2005
- 0 Post(s)
- 0 Thread(s)
Amend PHP with Xpath sorting
I've been trying to add some sort of Xpath to sort my XML with PHP, seems to be returning the correct amount of elements based on the criteria, but now no values are showing. No hotel name, no img, just empty div containers.
Can anybody spot what is causing the empty values, what am I doing wrong?
<?php $i=1; foreach ($hotels->hotel->xpath('//hotel/location[. ="some location"]') as $hotel): ?>
<?php $clss= ($i % 3 == 0)? 'class="last"':'' ?>
<div <?php echo $clss ?> >
<img src="images/<? echo $hotel->img->name ?>">
<h3><?php echo $hotel->name ?></h3>
<p><?php echo $hotel->description ?></p>
<p><b>Rating:</b> <?php echo $hotel->star ?></p>
<p><b>Location:</b> <?php echo $hotel->location ?></p>
<? endforeach ?>
<?php $i=1; foreach ($hotels->hotel as $hotel): ?>
BarryThe more you learn.... the more you learn there is more to learn.