Hi,
I have an xml file of products, I am not able to put the products in an array, it is empty , however when I ask the size of the array it tells me that I have products.
I thank you
<?php $url = 'http://sotelecom.cupomcampeao.com.br/allnations.xml'; $dom = new DOMDocument('1.0', 'utf-8'); $dom->load($url); $xpath = new DOMXPath($dom); $xpath->registerNamespace('xs', 'http://www.w3.org/2001/XMLSchema'); $elements = $xpath->query('//xs:element'); $produtos = $xpath->query('//Produtos'); echo "elements". $elements->length,PHP_EOL; echo "products". $produtos->length; echo "" ; if (!is_null($produtos)) { foreach ($produtos as $produto) { $num++; $TIMESTAMP[$num] = $produto->produtos->TIMESTAMP; echo "TIMESTAMP:". $TIMESTAMP[$num] ."
" ; } } ?>
Response in browser:
elements25 produtos273
TIMESTAMP:
TIMESTAMP:
TIMESTAMP:
TIMESTAMP:
TIMESTAMP:
TIMESTAMP: