CodeIgniter Forums
Problem with XML - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Problem with XML (/showthread.php?tid=36439)



Problem with XML - El Forum - 12-01-2010

[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?