Welcome Guest, Not a member yet? Register   Sign In
Problem with XML
#1

[eluser]Unknown[/eluser]
In the project i'm currently working on I get the following XML returned:

Code:
$response = '
<?xml version="1.0" encoding="UTF-8"?>
<epp >
  <response>
    <result code="1000">
      <msg>Command completed successfully</msg>
    </result>
    <resData>
      <domain:chkData>
        <domain:cd>
          <domain:name avail="true">DOMAINNAME.be</domain:name>
        </domain:cd>
      </domain:chkData>
    </resData>
    <trID>
      <clTRID>clientref-00029</clTRID>
      <svTRID>dnsbe-0</svTRID>
    </trID>
  </response>
</epp>
';

I need the value of the 'avail' attribute, so i make it a DOMXPath object:

Code:
$dom = new DOMDocument();
$dom->formatOutput = true;
$dom->loadXML($response);
$responsexPath = new DOMXPath($dom);

And use the following query:
Code:
$result = $responsexPath->query('/epp/response/resdata/domain:chkdata/domain:cd/domain:name@avail');

Without any success =(

What am I doing wrong and what is the right way to get the value of the 'avail' attribute?




Theme © iAndrew 2016 - Forum software by © MyBB