PHP
  Home arrow PHP arrow Working with Attributes and CDATA Sect...
CIO Insight
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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

Working with Attributes and CDATA Sections with the DOM XML Extension
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-03-04

    Table of Contents:
  • Working with Attributes and CDATA Sections with the DOM XML Extension
  • Reviewing some methods of the DOM XML extension
  • Working with the createAttribute() method
  • Inserting CDATA nodes into an XML document

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    Working with Attributes and CDATA Sections with the DOM XML Extension
    (Page 1 of 4 )

    Undeniably, one of the most remarkable strengths of PHP is its robust set of extensions. They provide developers with the right tools to build a huge variety of web applications with minor hassles. And this characteristic is particularly evident when it comes to working with XML documents, since PHP comes packaged with a bunch of powerful libraries that allow it to handle XML data in all sorts of clever ways.

    A good example of this is the popular “SimpleXML” extension, which comes in handy when performing the most common operation required to work with XML documents -- using an approachable, easy-to-learn API. You might think that this library is the only one bundled with PHP that can be used to handle XML data, but this is completely erroneous.

    There’s a PHP library that permits you to work with XML documents by using the DOM API. Does this name ring any bells for you? Yes, you’re right! Fortunately, PHP also provides programmers with the helpful DOM XML extension, which, as its name suggests, can be quite useful when processing XML documents via the Document Object Model.

    Basically, this implies that you’ll be able to build XML documents from scratch, create and append new nodes, remove existing ones, work with custom attributes, etc., by using the methods offered by the DOM API, which include the popular “createElement(),” appendChild(),” and “getElementById().”

    Of course, if you're used to working with JavaScript on a frequent basis, then the previous methods will be pretty familiar to you. But if you haven’t had the chance to develop client-side applications, you might want to read this article series to learn how to get started using the DOM XML extension bundled with PHP.

    And speaking of the numerous features offered by this library, in the first article of the series I explained how to use some of its simplest methods to perform certain basic tasks on XML data, such as building new documents, creating elements and inserting nodes, and finally echoing the whole output to a browser.

    However, this is merely a humble beginning, since the DOM XML library comes equipped with many other methods that can be useful for adding custom attributes to the existing nodes of a given XML document, and creating new CDATA sections, among other things. Therefore, assuming that all these topics are really interesting to you, in this second part of the series I’ll be discussing them in detail and logically accompanying the corresponding theoretical concepts with illustrative hands-on examples.

    Does all this material sound good to you? Great! Let’s continue this journey now!

    More PHP Articles
    More By Alejandro Gervasio


       · The DOM XML PHP library comes equipped with a bunch of methods that can be useful...
     

       

    PHP ARTICLES

    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5
    - Working with Multiple Document Nodes with th...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway