Using PHP Xpath loop to to get current value as a variable -
here xml:
<publications> <publicationsgroup> <publicationsgroupheading><![cdata[2013]]></publicationsgroupheading> <publicationslist> <publicationdetails> text1.....</publicationdetails> <publicationdetails> text2.....</publicationdetails> </publicationslist> </publicationsgroup> <publications/>
in php code want loop through publicationdetails elements , assing current value varaible.
here's php code:
foreach($publicationsgroupheadingyear->publicationslist $publicationslistbyyear ) { foreach($publicationslistbyyear->publicationdetails $publicationdetailsbyyear) { $publicationdetailsvalue = $publicationslistbyyear->publicationdetails; } }
i can seeem first value ('some text1') in $publicationdetailsvalue
that's because you're looping on <publicationdetails/>
, not using value.
use inner loop variable instead.
$publicationdetailsvalue = $publicationdetailsbyyear;
Comments
Post a Comment