Jump to content

Notice/Warning Error When Trying To Get Value From XML.


MoFish

Recommended Posts

Hi,

 

I'm trying to read the 'code' value "2303" from the following XML.

 

This is currently held in a string called $result.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="x">
  <response>
    <result code="2302">
      <msg>Object exists</msg>
      <extValue>
        <value>
          <domain:name
            xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
            xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd">
            google.co.uk
          </domain:name>
        </value>
        <reason>V094 Domain name exists already</reason>
      </extValue>
    </result>
    <trID>
      <clTRID>ABC-1234x5</clTRID>
      <svTRID>387210698x9</svTRID>
    </trID>
  </response>
</epp>

I have the following, but it is throwing me an error. I cant figure out what I'm doing wrong, as thought i had referenced it correctly.

$xml = simplexml_load_file($result);
$code = intval($xml->response->result['code']); //line 147
echo $code;

Notice: Trying to get property of non-object in class.php on line 147

Warning: simplexml_load_file(): I/O warning : failed to load external entity

 

Any help much appreciated.

 

MoFish

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.