PHP
  Home arrow PHP arrow Searching and Replacing Nodes with Sim...
Dev Shed Forums 
Administration  
AJAX  
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 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
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

Searching and Replacing Nodes with SimpleXML in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2006-06-26

    Table of Contents:
  • Searching and Replacing Nodes with SimpleXML in PHP 5
  • Going deeper into parsing XML strings: comparing nodes
  • Finding nodes inside a XML string: using the “Xpath()” method
  • Replacing nodes within a XML string: using the “asXML()” method
  • Using a few additional methods: finding child nodes, accessing attributes and using the XML DOM

  • 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


    Searching and Replacing Nodes with SimpleXML in PHP 5


    (Page 1 of 5 )

    Want to learn how to get the most out of the “simpleXML” extension that comes bundled with PHP 5? Welcome to the last part of the series “Working with simpleXML in PHP 5.” In three tutorials, this series covers topics ranging from the basics of parsing XML files with this library, to performing advanced tasks, such as searching, extracting and replacing nodes, and interoperating with the XML DOM.

    Introduction

    Quite possibly, if you’ve read the two preceding articles of this series, you’ll know how to load XML files and strings onto PHP objects by using the helpful “simplexml_load_file()” and “simplexml_load_string()” functions. You'll also know how to access parent and child XML nodes through a simple array syntax.

    Also, at this point you’ll realize that one of the best things about this extension is how easily you can use it for parsing XML data by using typical foreach loops, which makes all the XML processing operations a breeze. Here, there’s no need to deal with complex parsers. Once XML data has been stored in a PHP object, the process for accessing nodes is reduced to navigating the corresponding tree and calling the appropriate methods.

    So far, the couple of functions that I mentioned before actually do a good job of  parsing simple XML files and strings. However, the “simpleXML” library has a few additional handy functions that I’d like to show you in this last tutorial. That said, in the next few lines, I’ll be covering these functions, in order to demonstrate how to quickly search and replace nodes within XML data strings.

    So that’s the subject of this article. It’s time to continue learning about the “simpleXML” extension. Let’s do it together!

    More PHP Articles
    More By Alejandro Gervasio


       · In this last part of the series, you'll learn how to use some additional methods...
     

       

    PHP ARTICLES

    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter
    - Building Your Own System Tray Application Us...
    - Structuring Your Projects for Web Applicatio...
    - Inserting, Updating and Deleting Database Ro...
    - Building Your Own Desktop Notepad Applicatio...
    - Web Application Security Overview
    - Working with the Active Record Class in Code...
    - Generate PDF Documents with PHP on the Windo...
    - Sending Email with PHP Networking
    - Performing Strict Validation with the Code I...
    - The preg_replace_callback() function in PHP
    - PHP Networking
    - Validating Web Forms with the Code Igniter P...





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