HomePHP Working with Multiple Document Nodes with the DOM XML Extension in PHP 5
Working with Multiple Document Nodes with the DOM XML Extension in PHP 5
Welcome to the fourth article of the series "A quick overview of the DOM XML extension in PHP 5." By means of easy-to-grasp hands-on examples, this series equips you with a friendly guide to using the most relevant methods that come bundled with the DOM XML PHP extension to help you work with XML documents in a truly painless way.
If you’re a PHP developer who builds web applications that work with XML documents on a frequent basis, then there’s good news for you. This powerful server-side scripting language comes equipped with an extension, DOM XML, which permits you to handle XML data directly through the API provided by the Object Document Model.
Naturally, as with everything in life, learning the principal features offered by this XML-related PHP extension takes a while, but you can drive on the fast lane and save much of your time an effort by reading this group of articles right now!
At this point, having introduced the main subject of this article series, I’d like to spend a little time recapitulating the items that were discussed in the previous tutorial, just in case you didn’t have a chance to read it.
In that installment I explained how to use a couple of helpful methods included with the DOM XML extension, named “createComment()” and “createCDATASection()” respectively, which not surprisingly came in handy for inserting comments and CDATA nodes into an existing XML document.
Since appending comments and CDATA sections to a particular XML document tree was accomplished by using the DOM API, the whole process was simple, meaning that you shouldn’t have major problems understanding how these methods do their respective things.
So far, so good. At this stage, I quickly reviewed the topics treated in the previous article of the series, so it’s time to learn a few other methods included with the DOM XML extension. Based upon this premise, in this fourth tutorial I’m going to show you how to get access to multiple nodes of an XML document, either for internal processing or simply for echoing to the browser.
As you may have guessed, these multi-node operations require working with brand new methods of the DOM XML library, so let’s not waste more time in preliminaries.