First question posted here. I've tried to research this but either I'm not defining my question properly or I'm missing something obvious, so I'm bringing this to the group brain.
I'm writing a web app for a non-profit theatre I work for, using PHP. In this app, I use SimpleXML to pull down two XML documents from another location - one is a list of orders with price numbers, the other is a list of prices with price names.
What I'm trying to do, as simply and elegantly as possible, is iterate through the order document, find each price number ("price_id", a seven-digit number), go to the other document which also has those seven-digit numbers as well as a corresponding price name (price_name, which is"regular", "senior", "group", "student", "passholder", etc), and either - whichever is simpler - replace the number in the first document with the name from the second, or add an element following the number which has the corresponding price name, so that each patron shows up in the order document with a human-understandable price name instead of just a seven digit number that makes our box office staff go "huh?"
Psuedocode (from memory...):
$orders = simplexml_get_file(https://the-url-of-the-xml-order-document);
$prices = simplexml_get_file(https://the-url-of-the-xml-price-document);
foreach($orders->item->price_id as $price)
{
//...here inlies my question, but what I'd like to do is...
$price = $prices->item->(the price_name that corresponds to the price_id);
//...but I haven't found a simple way to do this, or really any way,
//based on my searches, but I know there has to be some way.
}
Thank you!