I have been struggling with this for quite a long time. I want to extract some data from an XML file (which I've written) and display it as part of a web page.
I know how to fetch all of the data and put it into HTML elements, but I need to display only some of it based on certain matches. For example; if I write a book review, I would want to display links to other related book reviews. I can't really explain it any better than that. Here is what I have so far:
<?php
$category = 'thriller';
$xml = simplexml_load_file('articlesxml.xml');
// ....and I'm stuck!
?>
Each section of the XML file is formatted as follows, but I could easily change it if doing so would make it easier to fetch the data:
<article>
<url>http://example.com/example-page.php</url>
<title>Book review</title>
<keywords>fiction,thriller</keywords>
</article>
I have read a few SimpleXML tutorials on the internet, but I haven't found the answer to this. They all seem to focus on fetching all occurrences of one XML element.