rahulragav Posted March 7, 2008 Share Posted March 7, 2008 Hi php-xml masters there ,warm greetings from this budding php guy..I'm new to this..and now caught up with a problem.. THE FOLLOWING is my code to extract data from a php class "simple.php" My task is to generate xml documents ,that i'm able to do now. <?php class compile1 { function compile1() { include "simple.php"; $obj = new request; $this -> filename = $obj -> filename; $this -> filepath = $obj -> filepath; } } $obj1=new compile1; $dom=new DOMDocument("1.0"); $dom->formatOutput = true; header("Content-Type:text/plain"); $root = $dom->createElement("request"); $dom -> appendchild($root); $filename = $dom -> createElement("filename"); $root -> appendchild($filename); $text = $dom->createTextNode($obj1->filename); $filename -> appendchild($text); $filepath = $dom->createElement("filepath"); $root -> appendchild($filepath); $text = $dom -> createTextNode($obj1->filepath); $filepath -> appendchild($text); echo $dom -> saveXML(); ?> the simple.php file (class) is <?php class request { public function request() { $this->filename="fibonacci.php"; $this->filepath="15.156.12.244/dirname"; } } ?> And output is as follows <?xml version="1.0" ?> - <request> <filename>fibonacci.php</filename> <filepath>15.156.12.244/dirname</filepath> </request> Now here are my problems.. 1.The tags in this XML output are hard coded.I want to make it dynamic i.e ,tags should be dynamically generated based on the class provided . 2.I ve to store this output in a file (.xml) and i have to retrieve each value of node by storing them against any variables ,so that other functions can access this xml elements using those variable names.. I tried diffrent ways and still trying. Any masters and experts reading this , please help. regards rahul.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.