WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - השוואת מחירים בסופר
ZeroLag.com
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Functions to add / remove nodes to / from an XML file using PHP.
Categories : PHP, XML Click here to Update Your Picture
pradnyesh kadam
Date : Mar 02nd 2010
Grade : 2 of 5 (graded 4 times)
Viewed : 13258
File : No file for this code example.
Images : No Images for this code example.
Search : More code by pradnyesh kadam
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
Like this code?
Show the author your appreciation.
 

<?php
function removNode($myXML, $node, $attribute, $id) {
   
$xmlDoc = new DOMDocument();
   
$xmlDoc->load($myXML);
   
$xpath = new DOMXpath($xmlDoc);
   
    if(
$attribute!='' || $id!='' )
   
$nodeList = $xpath->query('//'.$node.'[@'.$attribute.'="'.$id.'"]');
    else
   
$nodeList = $xpath->query('//'.$node.'');
   
    if (
$nodeList->length)
    {
       
$node = $nodeList->item(0)  ;
       
$node->parentNode->removeChild($node);
    }
   
$xmlDoc->save($myXML) ;
}   
?>




Example Usage
<?php
removNode
('content.xml','slideshow/slide','id', '10');
?>




Function to add NODES into XML FILE using PHP
<?php   
function addNode($myXML, $parentnode, $childnode, $attribute1, $value1, $attribute2, $value2, $attribute3, $value3 , $attribute4, $value4 , $attribute5, $value5, $text){
   
$doc = new DOMDocument();               
   
$doc->load($myXML);
   
   
$node = $doc->getElementsByTagName($parentnode)->item(0) ; // Node     
   
$slide = $node->appendChild(new DOMElement($childnode)) ;
   
    if(
$text != '')   
   
$slide->appendChild($doc->createTextNode($text));
   
    if(
$attribute1 != '')           
   
$slide->setAttributeNode(new DOMAttr( $attribute1, $value1 ));
   
    if(
$attribute2 != '')   
   
$slide->setAttributeNode(new DOMAttr( $attribute2, $value2 )) ;
   
    if(
$attribute3 != '')
   
$slide->setAttributeNode(new DOMAttr( $attribute3, $value3 )) ;   
   
    if(
$attribute4 != '')
   
$slide->setAttributeNode(new DOMAttr( $attribute4, $value4 )) ;   
   
    if(
$attribute5 != '')
   
$slide->setAttributeNode(new DOMAttr( $attribute5, $value5 )) ;   
       
   
$doc->save($myXML);       
}
?>


Example Usage
<?php
addNode
('content.xml', 'interactive', 'slide', 'id', '2', 'imgid', '5', 'order', '10', '', '', '', '', 'Text Here ...');   
?>



RSS parser. Parses RSS into an array. Quick and nasty but does the job. No checking is done for correct Tags, only correct XML. PHP4 needed to display result (uses print_r).
Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS)
Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript.
Categories : PHP, Java Script, DOM XML, XML, Arrays
XPath for PHP without the DOM XML extension
Categories : DOM XML, XML, XSLT, PHP Classes, PHP
DBXML- A Class to backup databases in XML Format using web interface
Categories : PHP, PHP Classes, Databases, MySQL, XML
XML To Array
Categories : PHP, PHP Classes, XML, Arrays
php Free chat simple fast and customizable chat server that uses a simple filesystem for message and nickname storage
Categories : PHP, AJAX, XML, Complete Programs
XML easy parser
Categories : PHP, XML
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases
XMLManipulation
Categories : PHP, XML, SimpleXML
XML Menu
Categories : PHP, PHP Classes, Navigation, XML, XSL
MySQL to XML.
Categories : MySQL, XML, PHP
Simple newsreader script
Categories : PHP, XML, Rich Site Summary (RSS)
Freshmeat.net XML-RPC - This class is meant to query Freshmeat for information about registered projects.
Categories : PHP, PHP Classes, XML, Web Services
Glossword - glossary compiler
Categories : Content Management, PHP, MySQL, XML
XML easy parser
Categories : PHP, XML, PHP Classes