XML & XSLT
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.
Important: if this is the first time you're working with XML, I strongly recommend you skip everything else and go straight to the SimpleXML module - it's the easiest way of working with XML, and it's the only thing I use nowadays.
Topics covered in this chapter are:
Standard XML manipulation
"SimpleXML" - the fast and easy way to use XML
XSL and transforming XML
- 12.1. Introduction to XML
- 12.2. Event-based parsing
- 12.2.1. Creating a parser
- 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
- 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