ConFoo Montreal 2026: Call for Papers

Voting

: max(seven, one)?
(Example: nine)

The Note You're Voting On

harry at nospam dot thestorm dot plus dot com
13 years ago
To read a namespace node you have to use the children method.

<?php

$xml
= <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<people xmlns:p="http://example.org/ns" xmlns:t="http://example.org/test">
<p:person id="1">John Doe</p:person>
<p:person id="2">Susie Q. Public</p:person>
</people>
XML;

$sxe = new SimpleXMLElement($xml);

$ns = $sxe->getNamespaces(true);

$child = $sxe->children($ns['p']);

foreach (
$child->person as $out_ns)
{
echo
$out_ns;
}

?>

<< Back to user notes page

To Top