Icon

Just Some Shit I Thought And Wrote.

Appending XML To Existing XML Document (PHP)

I was recently tasked to write a system that involves a lot of XML transfer between two or more systems, in some cases the XML needs to be appended and then transfered, I struggled for a bit with the appending but soon bumped into a function that did the trick… If you have an extender class, just simply copy and paste…

<?php

class SimpleXMLExtended extends SimpleXMLElement{

public function Attribute($name){
/**
* manipulate xml attributes
*/
foreach($this->Attributes() as $key=>$val){
/**
* attribute found, return the value
*/
if( strcasecmp($key,$name) == 0 ){
return (string)$val;
}
}
}

}

?>

Hope you find it useful…

Category: PHP, Techno

Tagged: , ,

Leave a Reply