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

Chapter contents

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

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Introduction to XML >>

Previous chapter: Next chapter

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.