|
|
|
|
|
|
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 | |
| |
| |
|