I am trying to do a search to get a url in PHP
I have tried
$the_id = $item['id'];
$nodes = $xml->xpath("//item[contains(g:id,'$the_id')]");
foreach($nodes as $node) {
$url = $node->g:link;
}
How do I do it?
$url = $node->g:link; gives a syntax error
Do I ignore g: and use id and link
Thanks
The xml layout is
<item>
<g:id>2023</g:id>
<g:title> Croquet Set - Townsend </g:title>
<g:description>
Already a very popular set, the Townsend croquet set is now available in a more portable canvas carry bag. Perfect for people who wish enjoy croquet on the go. The Garden Games Townsend Croquet set has four beautifully crafted croquet mallets with attractive Rosewood mallet heads and solid Ash wood handles with leather bound grip for comfort, less vibration when hitting the solid 16oz composite regulation sized balls giving better accuracy.
This high quality croquet set is easy to store in the strong and durable canvas carry bag. The set easily packs back into its storage bag ready for the next game.
</g:description>
<g:link>
</g:link>
<g:image_link>
https://www.biggamehunters.co.uk/acatalog/Townsend-in-a-bag_1.jpg
</g:image_link>
<g:condition>New</g:condition>
<g:availability>in stock</g:availability>
<g:price>164.99 GBP</g:price>
<!--
<g:shipping>
<g:country></g:country>
<g:service></g:service>
<g:price> </g:price>
</g:shipping>
<g:shipping_weight> kg</g:shipping_weight>
-->
<g:gtin>5035874202309</g:gtin>
<g:brand>Garden Games</g:brand>
<!--
The following attributes are required for apparel and accessories, media and software; recommended otherwise
-->
<g:google_product_category>Sporting Goods > Outdoor Recreation > Lawn Games</g:google_product_category>
<g:product_type>Croquet > Croquet Sets</g:product_type>
</item>