Hudzilla.org - the homepage of Paul Hudson
Contents > Wish List | Report Bug | About Me ]

12     XML & XSLT

This is NOT the latest copy of this book; click here for the latest version.

We all know that XML has great advantages going for it - it is human-readable, cross-platform, and easily converted into other forms. However, we all also know that it is not the fastest kid on the block when put up against binary formats.

So, how does a web developer harness the power of XML, whilst retaining as much performance as possible? Simple - use PHP's exceptionally fast XML module!

This chapter will teach XML parsing and manipulation using PHP, and requires that you are familiar with PHP as a language. Some familiarity with XML is required, although XML syntax and grammar is not mentioned in detail - the focus is PHP.

Topics covered in this chapter are:

  • Standard XML manipulation

  • "SimpleXML" - the fast and easy way to use XML

  • XSL and transforming XML


Chapter contents

12.1. Introduction to XML
12.2. Event-based parsing
12.2.1. Creating a parser: xml_parser_create() and xml_parser_free()
12.2.2. Getting to know callback functions
12.2.3. Callback function implementation
12.2.4. Event-based XML parsing, at last!
12.2.5. Bringing Everything Together
12.3. SimpleXML
12.3.1. First steps
12.3.2. Reading from a string
12.3.3. Searching and filtering with XPath
12.3.4. Outputting XML: asXML()
12.4. Transforming XML using XSLT
12.4.1. Adding PHP to the mix
12.4.2. Handling the processed output
12.4.3. Making XSL work for its money
12.4.4. What else can XSL do?
12.4.5. XSLT Conclusion
12.5. Summary
12.6. Exercises
12.7. Further reading
12.8. Next chapter



<< 11.9 Next chapter   12.1 Introduction to XML >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
hw.skraus4709@friendly-email.com - 24 Jul 2008

cool site.

A PHP User - 24 Jul 2008

Please cover more data for XSL area as it is in demand.
(Portals are more famous now-a-days)

m.mueller www.phperror.com - 24 Jul 2008

@James:
The limitation is the capacity of your server and the settings in the php.ini (max execution time and max amount of mem to use)

James - 24 Jul 2008

I've tried using the SimpleXML module with a large XML file and it feel over, is there a limit to how big the XML file can be ?



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is three plus ten?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow