I never asked questions here, so please forgive my question if it is poorly formatted or not well defined. I am just a dabbler and know very little about PHP and XPath.
I have an XML file:
<catalogue>
<item>
<reference>A1</reference>
<title>My title1</title>
</item>
<item>
<reference>A2</reference>
<title>My title2</title>
</item>
</catalogue>
I pulled this file using SimpleXML:
$file = "products.xml";
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
Then I use the link from the URL parameter to get additional information about the "element" using PHP:
foreach ($xml->item as $item) {
if ($item->reference == $_GET['reference']) {
echo '<p>' . $item->title . '</p>';
}
So, from a URL like www.mysite.com/file.php?reference=A1
I would get this HTML:
<p>My title1</p>
I understand that I may not be doing it right, and any recommendations for improving it are welcome.
: . URL-, reference = A1, , .. ""? "A1", , node, HTML :
<p>Next item is My title2</p>
, , . node, , .
.