SimpleXML - Call to a member function children() on a non-object

Hello all,

Given 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>
            <transfer op="request">
                <domain:transfer 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></domain:name>
                </domain:transfer>
            </transfer>
            <extension>
                <ptdomain:transfer 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></ptdomain:roid>
                    <ptdomain:transferKey></ptdomain:transferKey>
                </ptdomain:transfer>
            </extension>
            <clTRID></clTRID>
        </command>
    </epp>

I was expecting access the name property like so:


$xmlObj = simplexml_load_file(self::PATHXML.'EppTransferDomain.xml');
$xmlObj->comand->transfer->children(self::OBJ_URI_DOMAIN)->transfer->name = $dominioVo->getNome();

Instead, a fatal error occurs:
Call to a member function children() on a non-object

I have dump $xmlObj and it IS an object.

Here’s the dump:


object(SimpleXMLElement)#9 (1) {
  ["command"]=>
  object(SimpleXMLElement)#6 (3) {
    ["transfer"]=>
    object(SimpleXMLElement)#8 (1) {
      ["@attributes"]=>
      array(1) {
        ["op"]=>
        string(7) "request"
      }
    }
    ["extension"]=>
    object(SimpleXMLElement)#11 (0) {
    }
    ["clTRID"]=>
    object(SimpleXMLElement)#12 (0) {
    }
  }
}

What am I doing wrong this time? :frowning:

Thanks in advance,
Márcio

Just spot it!! :wink:

AHrrrrhhh!!! Those are the worst. Absolutely!!!

Thanks for looking up. :slight_smile:

How many times does the letter M occur in the word “command”? Think about it … :wink: