newbie: php & xml

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
php 4.4.2

This code below generates a XML result which get stored in the $result

$result = '';
$url = " ";
$url = $url . '?Service=AWSECommerceService';
$url = $url . '&AWSAccessKeyId=xxxxxxxxxxxxxxxxxx';
$url = $url . '&Operation=ItemSearch';
$url = $url . '&Keywords=business';
$url = $url . '&SearchIndex=Books';
$url = $url . '&Sort=salesrank';
$url = $url . '&ResponseGroup=Medium';
$url = $url . '&Style=XML';
$result = file_get_contents($url);

Now I'm looking for a good/simple method to access the values in this xml
tree. I will only read (Not do any update)... But I'm not sure what's the
best way to do this....

I've run phpinfo() do get info about xml suppport at my ISP:
      XML Support  active
      XML Namespace Support  active
      EXPAT Version  1.95.6

      XSLT support  enabled
      Backend  Sablotron
      Sablotron Version  1.0.1

I've tryed using domxml_open_mem, but I get this error:
Call to undefined function: domxml_open_mem()
What is causing this error?

Please, what is the best method to access these values in my xml data  

If you have some links to a php tutorial showing how to do this, then I  
would be happy if you could send me the link


Re: newbie: php & xml

1. "What is causing this error?"

You are probably receiving this error because php is not loading the
php_domxml.dll extension.  This extension is requried for the function
you are trying to use.

Make sure you have the php_domxml.dll file and then add the following
to your php.ini configuration file.

2. "I'm looking for a good/simple method to access the values in this
xml tree."

The easiest way to read the values of an XML document is to load the
entire document into a multidimensional array.  This method is not
bullet-proof because XML documents can have attributes and can have
elements of the same name.  If your document's structure is reliably
consistent, then with a good algorithm, you shouldn't have any

I have yet to find a solid function/class that creates a
multidimensional array from an xml document.  Probably because there is
no solid way of doing it.  But here are a few that should at least

Good Luck

Site Timeline