Jump to content

php-xml help,plzzz


rahulragav

Recommended Posts

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.