Help me please. How to get the contents of the price tag if the contents of the name tag are known. My attempts:
<?php $title = "item-name" $stocks = simplexml_load_file('http://website.com/upload/stocks.xml'); $stocks = $stocks->xpath('/item/[name=$title]/price'); foreach($stocks as $stock) { echo $stocks->price; } ?> XML file:
<data vendor="SONEX" date="2016-10-28T18:07:45"> <items> <item> <name>2590/2W</name> <price>2675</price> </item> <item> <name>2599</name> <price>53845</price> </item> </items> </data>