PHP
  Home arrow PHP arrow Parsing Child Nodes with the DOM XML extension in PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Parsing Child Nodes with the DOM XML extension in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2008-04-08


    Table of Contents:
  • Parsing Child Nodes with the DOM XML extension in PHP 5
  • Reintroducing a few methods of the DOM XML extension
  • Working with the hasChildNodes() method
  • The removeChild() method

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Parsing Child Nodes with the DOM XML extension in PHP 5
    ( Page 1 of 4 )

    In this last chapter of the series, I’m going to teach you how to handle the child nodes of an XML document by way of two simple methods, called hasChildNode() and removeChild() respectively. So let’s not waste any more time in preliminaries and learn how to use them in a helpful way.

    During your life as a PHP developer, it’s quite possible that you've already built web applications that work with XML documents that needed to be parsed in one form or another. Of course, based on your own experience, you know that this process can be challenging, since handling XML data requires frequently traversing document nodes, dealing with attributes, copying elements from one place to another, and so forth.

    Fortunately, PHP comes packaged with a powerful extension, called DOM XML, that can be used to work on XML documents by using the API provided by the Document Object Model (commonly known as DOM). Thus, if you wish to learn the most important methods provided by this XML library, then this series of articles may be what you’re looking for.

    Welcome to the final part of the series “A quick overview of the DOM XML extension in PHP 5.” It is made up of seven approachable tutorials that go through some of the most relevant features that come bundled with this helpful PHP extension and is aimed at parsing XML documents in a painless way.

    Having already established the objective of this series of articles, now I’m going to briefly rehash the items that were treated in the preceding tutorial, so you can link them more easily with what I plan to discuss in this last installment. In the aforementioned article, I demonstrated how to retrieve the attributes corresponding to a certain number of nodes within an XML document via the “getAttribute()” method.

    In addition to teaching you how to work with the previous method, I showed you another one, called “hasAttribute()”, which came in handy for determining whether a particular element of an XML document contained an attribute or not. And lastly, I finished the tutorial by teaching you how to clone different nodes using the “cloneNode()” method, which is a process that hopefully was quite easy to understand.

    So far, so good. At this stage, you’re armed with the right pointers to start using some of the most useful methods that come included with the DOM XML extension. However, the question that comes up now is:  are there any additional features that still remain uncovered? Actually, this library has many other methods that can be useful for parsing XML documents, but in this last part of the series, I’ll be covering only a couple more. If you want to have a full reference guide on the DOM XML extension, the best place to go is the official PHP website.

    Let’s get started now!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT