Zend - The PHP Company




Code Gallery: SolFolango


XML Parsing/Output  

Type: class library
Added by: SolFolango
Entered: 25/08/2000
Last modified: 08/12/1999
Rating: **** (23 votes)
Views: 20793
With this easy to use classes (Node and XML) you can parse a XML file into a tree-equivalent instead of using the event-based parsing that PHP provides. All nodes (=elements) are inserted in an array, with data and attributes stored. This array can be then accessed. As an example, I wrote a function "print_nodes()" that prints the nodes in a nicely formatted way (similar to what IE5.5 does, when it encounters a XML file). Based on this example, you should easily work with the class (extending it). I hope, there are enough comments on this. Ah, forgot to mention: The print_nodes() can be formated with the vars $format_X in the XML-class. There are formatting possibilities for the element name, attributes, attribute values, the brackets, the identation etc. Fixed in v0.2 Node-print_name bug.




Search