I am looking to extract data from an XML feed containing information on books.
The feed is set up like this:
Now, having set the parent node as 'product', I can access the title and price data without any problem.
Here's the code I've got at the moment, but how do I amend it to access the 'author' information from the 'fields' node?
//initialise xml parser
$dom = new DOMDocument();
$domNode = $xmlReader->expand();
$element = $dom->appendChild($domNode);
$domString = utf8_encode($dom->saveXML($element));
$product = new SimpleXMLElement($domString);
$name = $product->name;
$product_url = $product->url;
$price = $product->price;
$author = $product->author;
$rank = $product->rank;
//insert query into database
$query = mysql_query("REPLACE INTO db_namet
(rank, title, author, price, url)
VALUES ('$rank', '$name', '$author', '$price', '$product_url')");
echo $product_name . "has been inserted </br>";
Thanks very much in advance for your help
$author = $product->fields->author;