Add class to name and order XML with XPATH

Hi all

I have a XML file holding all my content - a list of hotels which is displayed with PHP as shown below adding a class=“last” to every third element, works good.
My problem now, I need to add another class of class=“featured” and extra markup <span>featured</span> to a unique hotel name(s) and maybe sometimes at random.
The featured class might also be needed on the third element which already has the class=“last”.

How do I achieve this with the code below?

My existing code:

<?php $hotels = simplexml_load_file("hotel_listing.xml"); ?>
<?php $i=1; foreach ($hotels->hotel 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>
            </div>
            <? $i++;?>
            <? endforeach ?>

I would also like to order the hotels using some to sort of xpath.
I did try the below nothing happened…

<?php $hotels->xpath("star"); ?>

Any feedback much appreciated :cool:

Barry

If it helps… this is the output I already have and the featured output that I’m trying to achieve at the bottom.

<div>
                    <img src="images/hotel1.jpg">
                    <h3>hotel1</h3>
                    <p>Hotel description....</p>
                    <p><b>Rating:</b> 4</p>
</div>
<div>
                    <img src="images/hotel2.jpg">
                    <h3>hotel2</h3>
                    <p>Hotel description....</p>
                    <p><b>Rating:</b> 3</p>
</div>
<div class="last">
                    <img src="images/hotel3.jpg">
                    <h3>hotel3</h3>
                    <p>Hotel description....</p>
                    <p><b>Rating:</b> 4</p>
</div>

The featured markup and class I’m trying to add.

<div class="featured">
                   <span>featured</span>
		<img src="images/hotel4.jpg">
                    <h3>hotel4</h3>
                    <p>Hotel description....</p>
                    <p><b>Rating:</b> 4</p>
</div>

Thanks