phpXML is a class for accessing XML documents through the powerful XPath language WITHOUT requiring the DOM XML extensions to be setup on your server.
phpXML is a class for accessing XML documents through the powerful XPath language WITHOUT requiring the DOM XML extensions to be setup on your server. With this script XPath becomes at last also everywhere available, where hosters refuse persistently to setup this extension.
DOMIT! RSS is an RSS feed parser written purely in PHP. It therefore does not require the installation of any PHP extensions.
Unlike most other PHP RSS clients, it uses a DOM XML parser -- DOMIT! -- to convert an RSS feed into a DOM document that can be traversed using the standard DOM methods.
DOMIT! RSS is able to parse all versions of RSS formats. Its API is designed to work identically across all versions.
Its caching mechanism saves a local copy of the RSS feed and updates it only at specified intervals. It is able to detect certain types of non-compliant XML and repair it.
A lightweight DOMIT! RSS Lite class is available for users who wish only to extract title, link, and description elements from a feed.
This class is meant to read and write XML documents implementing the DOM API using the PHP XML functions based on the Expat library.
The class is able to open an XML document, parses it, and lets the developer change anything in the document: add nodes, set attributes, remove attributes, clone nodes, insert children, etc..
A PHP XML class to access Amazon API they released
Hello,
Now everybody heard of Amazon.com. What not everybody knows that Amazon released an API to access its huge catalogs. What this basically means is that each developer can access the information from Amazon following some simple protocols and every site owner can enhance his own website with content and features from Amazon.
The Amazon API comes as a simple Webservice. Here are the first Web services that they have exposed:
- Product Display : The ability to search for and retrieve product information from the Amazon.com catalog.
- Shopping Cart : The ability to add Amazon.com products to shopping carts, wish lists, and registries from third party locations.
No matter of your intentions, you will first need to register and obtain a valid developer token. You can get your token here at this address: http://www.amazon.com/webservices
The current listed implementation of Amazon webservices uses Keyword searches. It has basically the same results as searching the books catalog online. As any developer/webmaster can see in the "Amazon.com Web Services Developers Kit v 1.0" document, a lot of other Amazon features are exposed. This would imply extending the base structure I present here.
There are multiple approaches from a developer's point of view. The simplest one deals with SOAP and web services classes already implemented in PHP. You could also extend the PEAR's XMLParser object to parse Amazon results. The reason I did not choose these directions is because they require additional extensions installed with PHP. What I currently use is the XML parsing package that comes embedded in PHP, so it is slightly more general.
What basically happens in this implementation is that the search word entered by the used is embedded into a XML url that is then retrieved from Amazon.com. Then PHP builds a nice display for the information received.
I should let the code talk for itself. Here is the main controller, with a small search form for Amazon:
http://www.php9.com/php/source/amazon.phps
As you see, the actual code is very small. Then here is the class used in the controller to parse the XML returned by Amazon.
http://www.php9.com/php/source/amazon_class.phps
Then the configuration file. I need to remember you that you need to change the DEVELOPER_TOKEN constant with the one you will obtain from Amazon. The current license key belongs to me. You also need to change the ASSOCIATE_ID constant with a one from Amazon. You also need to do the same change in the file php9-data-to-html.xsl, the engine for the XSLT transformation.The current constant set belongs to me also.
http://www.php9.com/php/source/amazon_config.phps
And here is the layout template used to build the output from the XML document retrieved from Amazon. It is parsed every time a book record is retrieved, so the output rendering is the fastest possible.
http://www.php9.com/php/source/amazon_layout.phps
And here is the XSLT document used to build the HTML product page document from the XML document retrieved from Amazon.
http://www.php9.com/php9-data-to-html.xsl
Here you have the full package zipped.
http://www.php9.com/php/source/amazon.zip
And of course a demo: http://www.php9.com/amazon.php
As the project improved a lot during the latest months, I created a freshmeat project here:
http://freshmeat.net/projects/amazon_webservice_api/
and a class collection in the extensive package provided by Manuel Lemos:
http://www.phpclasses.org/browse.html/package/642.html
Feel free to use it and improve. I am open to suggestions.
The class has been updated to use Amazon Webservices Version 2 (search order, number of results).
- Parses arbitrary XML input and builds an array with the structure of all tag and data elements.
- Optionally, keeps track of the positions of each element to allow the determination of the exact location of elements that may be contextually in error.
- Supports parsed file cache to minimize the overhead of parsing the same file repeatdly.
- Optimized parsing of simplified XML (SML) formats ignoring the tag attributes.
Easy class takes XML data and makes it into objects named as the tags in the XML data, with the cdata for values.
Easy class takes XML data and makes it into objects named as the tags in the XML data, with the cdata for values. Can also be used for statistics on the
XML file. See http://www.hansanderson.com/php/xml/ for more information and samples.