Jump to content

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


MoFish
Go to solution Solved by requinix,

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.