I'm quite new to SimpleXML and using xpath within it. I wasn't sure whether to post this query within the original posting or here, so I linked to here form the original posting.
In working through several test scripts, I came across this posting, and I've been attempting to make one of the accepted answers work. However, when I attempt to use the xpath version of the accepted answer work, I get the error message:
Undefined offset: 0
I've tested xpath in other ways, to verify that it is installed and functional. Thanks for any leads.
I have duplicated the OP's xml file, along with the accepted answer code:
XML:
<data>
<poster name="E-Verify" id="everify">
<full_image url="e-verify-swa-poster.jpg"/>
<full_other url=""/>
</poster>
<poster name="Minimum Wage" id="minwage">
<full_image url="minwage.jpg"/>
<full_other url="spa_minwage.jpg"/>
</poster>
</data>
PHP Code:
<?php
$url = "test_b.xml";
$xml = simplexml_load_file($url);
$main_url = $xml->xpath('name[@id="minwage"]/full_image')[0];
?>