Jump to content

Need to convert PHP 5 DOM code to PHP 4 XML DOM....????


angelleye

Recommended Posts

I developed a PayPal solution for my client but I have PHP 5.2 installed on my development server.  I made the mistake of assuming my client's host would also have PHP5.  Of course, they're using PHP 4.4 so now all of my DOM code that parses XML responses does not work.

 

I always have trouble understanding php.net for some reason.  I tend to do better with tutorials/guides people write out and show lots of nice sample code.  I can't seem to find anything like that for PHP 4 XML DOM besides php.net.  I just don't follow it for some reason. 

 

Anyway, here is a short snippet of code that does not work in PHP 4 because I'm using PHP5 DOM instead of PHP4 XML DOM.  If I could get some information ( or sample code would be great ) now how to convert this so it will work with PHP4 XML DOM then I think I can handle converting the rest of my stuff. 

 


$xmlDOM = new DOMDocument();

$xmlDOM -> loadXML($SOAPResponse);

$xPath = new DOMXPath($xmlDOM);

$xPath -> registerNamespace("pp", "urn:ebay:api:PayPalAPI");
$xPath -> registerNamespace("ebay", "urn:ebay:apis:eBLBaseComponents");

$FaultCode = $xmlDOM -> getElementsByTagName("faultcode");

if($FaultCode -> length > 0)
{
      $FaultCode = $FaultCode -> item(0) -> nodeValue;
      
      $FaultString = $xmlDOM -> getElementsByTagName("faultstring");
      $FaultString = $FaultString -> item(0) -> nodeValue;
      ?>
    </p>
    <table width="500" border="0" align="center" cellpadding="2" cellspacing="2">
      <tr>
        <td width="129" align="right" valign="top"><strong>Fault Code:</strong></td>
        <td width="357" align="left" valign="top"><?php
            echo $FaultCode;
            ?>        </td>
      </tr>
      <tr>
        <td align="right" valign="top"><strong>Fault Message:</strong></td>
        <td align="left" valign="top"><?php
            echo $FaultString;
            ?>        </td>
      </tr>
    </table>
    <?php
      die();
}

 

Any info would be greatly appreciated.  Thanks!!

 

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.