Hello all,
I’m trying to echo: “example.pt” from the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
<domain:name>example.pt</domain:name>
<domain:curExpDate>2008-04-03</domain:curExpDate>
</domain:renew>
</renew>
<extension>
<ptdomain:renew xmlns:ptdomain="http://eppdev.dns.pt/schemas/ptdomain-1.0" xsi:schemaLocation="http://eppdev.dns.pt/schemas/ptdomain-1.0 ptdomain-1.0.xsd">
<ptdomain:roid>26368</ptdomain:roid>
<ptdomain:notRenew>true</ptdomain:notRenew>
</ptdomain:renew>
</extension>
<clTRID>renew-02</clTRID>
<bla>blabla 1</bla>
<poing>Poing 1</poing>
</command>
</epp>
This works perfectly:
$xmlObj = simplexml_load_file('RepositorioXml/EppRenewResponse.xml');
foreach ($xmlObj->command as $comando)
{
echo $comando->clTRID;
echo '<br />';
echo $comando->bla;
echo '<br />';
echo $comando->poing;
}
This doesn’t work - ie, I can’t see nothing displaying.
I have var_dump a lot after the first foreach and I’m always getting 0.
echo '<br /> Value inside namespaced elements:<br />';
foreach ($xmlObj->command as $comando)
{
//var_dump($comando); //getting: all nodes inside, including those with
//namespaces, but, those, however, are returned without any values, and
//object(SimpleXMLElement)#4 (0) are returned instead. :s
//var_dump($comando->extension); //getting: object(SimpleXMLElement)#4 (0) { }
foreach ($comando->extension as $extensoes)
{
//var_dump($comando->extension); //getting: object(SimpleXMLElement)#8 (0) { }
$ns_domain = $extensoes->children('urn:ietf:params:xml:ns:domain-1.0');
//var_dump($ns_domain); //getting: object(SimpleXMLElement)#8 (0) { }
echo $ns_domain->name;
}
}
Can anyone give me a hand here please?
Thanks a lot in advance,
Márcio