PHP XML Classes
RDDL Parser (class_rddl_parser.php)
Downloads at Sourceforge

Description: This class can be used to parse RDDL documents. An RDDL document is an XHTML document with special <resource> elements. This class parses the resources described in the RDDL and provides a method to return a PHP array containing the information about the RDDL resources. After parsing the document and retrieving the resources you can do whatever you want with them. RDDL documents can be parsed from URLs or files.

NEWS:
  • 06-20-2002 First version of this class released.
This class code as well as documentation are hosted at SourceForge please visit our SourceForge page for releases, documentation, bug-tracking, support forums and mailing lists.

Resources Requirements
  • PHP 4.0.5+

Features To-dos
  • All the RDDL resource attributes can be retrieved.
  • If you want to add some feature to this class let me know it.

Contact: Luis Argerich (lrargerich@yahoo.com)

Detailed description and usage:

See the rddldump.php example for a good description about how to use this class.

An example:
include_once("class_rddl.php");
$rddl=new RDDL_parser();
$rddl->rddl_parse("http://www.rddl.org/");
$resources=$rddl->get_resources();



Documentation

Classes

RDDL_parser

Extends: None
Description: This class can be used to parse a RDDL document from a file or a URL and then it can be asked to return an array containing information about all the RDDL resources found on the file. The information can be used as you want.

Method Summary
 string get_error()
          Returns the error message if there was a problem parsing the RDDL document
 Boolean rddl_parse(string $rddl)
          Parses an RDDL document
 Array get_resources(string $rddl)
          Returns resources found after parsing an RDDL document
 

Method Detail

get_error

string get_error()
This method returns an error message when rddl_parse returns false.
 
Parameters:
Returns:
The last error message.
Throws:
None

rddl_parse

Boolean rddl_parse(string $rddl)
This method is called to parse an RDDL document from a URI or file.
 
Parameters:
$rddl - URL or filename of the RDDL document to be parsed
Returns:
True if the document was parsed succesfully, false if there was an error.
Throws:
None

get_resources

Array get_resources(string $rddl)
This method returns an array containing the RDDL resources found in the parsed RDDL document.
 
Parameters:
Returns:
An array of asociative arrays, each member of the array is a resource found in the RDDL document. Each member is an asociative array describing the resource, typical keys are: role, href, arcrole, type, title, id
Throws:
None