Sort SimpleXml Output by price
Posted: Tue Nov 24, 2009 11:46 am
Hi,
i'm I'm trying to pull products from two xml feeds(like a feed mashup or something).
What i already achieved is to parse the feed and display them correctly, but i can only show one feed results at a time.
My questions would be: How to show the results from both feeds at a time and sort products by the string price.
Mybe it's wrong that i'm using the same variable names( $xml, $items)..
Here are the two codes i'm using:
Thanks in advance.
i'm I'm trying to pull products from two xml feeds(like a feed mashup or something).
What i already achieved is to parse the feed and display them correctly, but i can only show one feed results at a time.
My questions would be: How to show the results from both feeds at a time and sort products by the string price.
Mybe it's wrong that i'm using the same variable names( $xml, $items)..
Here are the two codes i'm using:
Code: Select all
$xml = simplexml_load_file('cars.xml.php');
foreach ($xml as $item) {
$link = $item->link
$title = $item->product-name;
$price = $item->formatted-price;
$output .="<div><a href=\"$link\"> $title</a></br>Price:$price</div>";
}
$xml = simplexml_load_file('trucks.xml.php');
foreach ($xml as $item) {
$link = $item->buyurl;
$title = $item->name;
$price = $item->price;
$output .="<div><a href=\"$link\"> $title</a></br>Price:$price</div>";
}
Thanks in advance.