I\'m learning how to parse XML with PHP\'s simple XML. My code is:
For the part about the default namespace, read fireeyedboy's answer. As mentionned, you need to register a namespace if you want to use XPath on nodes that are in the default namespace.
However, if you don't use xpath()
, SimpleXML has its own magic that selects the default namespace automagically.
$xmlSource = " myApp ";
$Document = new SimpleXMLElement($xmlSource);
foreach ($Document->iTunes as $iTunes)
{
echo $iTunes, PHP_EOL;
}