Loading ...
Sorry, an error occurred while loading the content.

How to read the file tag by tag

Expand Messages
  • dhana_1706
    Hi, kindly anyone tell me how to read the XML file tag by tag? Thank u, dhana
    Message 1 of 5 , Sep 11, 2007
    • 0 Attachment
      Hi,

      kindly anyone tell me how to read the XML file tag by tag?

      Thank u,
      dhana
    • deepu kumar
      Hello, I used dom document for getting data from Xml file $doc = new DOMDocument();// creating object $doc- load( book.xml );// loading the xml file to read
      Message 2 of 5 , Sep 11, 2007
      • 0 Attachment
        Hello,
        I used dom document for getting data from Xml file
        $doc = new DOMDocument();// creating object
        $doc->load('book.xml');// loading the xml file to read
        $params = $dom->getElementsByTagName('param');//returns nodes list as array

        foreach ($params as $param)
        {
        echo $param ->nodeName'<br>';
        echo $param ->nodeValue'<br>';
        }

        This is only for one level. if there are multi levels we have to write the inner Loop in the for Loop

        Eg:
        foreach ($params as $param)
        {

        foreach ($param as $Child)
        {
        echo $Child->nodeName'<br>';
        echo $Child->nodeValue'<br>';
        }
        }

        bye,

        dhana_1706 <dhana_1706@...> wrote:

        Hi,

        kindly anyone tell me how to read the XML file tag by tag?

        Thank u,
        dhana






        ---------------------------------
        Did you know? You can CHAT without downloading messenger. Click here

        [Non-text portions of this message have been removed]
      • siva prem
        dhana, you can use some XML Libaray and get the xml to convert to array format and loop thru it. search for xml libaray. if u can t find let me know. regards
        Message 3 of 5 , Sep 12, 2007
        • 0 Attachment
          dhana, you can use some XML Libaray and get the xml to convert to
          array format and loop thru it.

          search for xml libaray. if u can't find let me know.

          regards
          Siva


          --- In bang-phpug@yahoogroups.com, "dhana_1706" <dhana_1706@...> wrote:
          >
          >
          > Hi,
          >
          > kindly anyone tell me how to read the XML file tag by tag?
          >
          > Thank u,
          > dhana
          >
        • siva prem
          Check the files in the techgroup, have added a xml parsing script.
          Message 4 of 5 , Sep 12, 2007
          • 0 Attachment
            Check the "files" in the techgroup, have added a xml parsing script.


            --- In bang-phpug@yahoogroups.com, "dhana_1706" <dhana_1706@...> wrote:
            >
            >
            > Hi,
            >
            > kindly anyone tell me how to read the XML file tag by tag?
            >
            > Thank u,
            > dhana
            >
          • deepu kumar
            Sorry i forgot to keep statement for getting child node $doc = new DOMDocument();// creating object $doc- load( book.xml );// loading the xml file to read
            Message 5 of 5 , Sep 12, 2007
            • 0 Attachment
              Sorry i forgot to keep statement for getting child node

              $doc = new DOMDocument();// creating object
              $doc->load('book.xml');// loading the xml file to read
              $params = $dom->getElementsByTagName('param');//returns nodes list as array
              foreach ($params as $param)
              {
              $child=$param->childnodes;
              echo $child ->nodeName'<br>';
              echo $child->nodeValue'<br>';
              }
              This is only for one level. if there are multi levels we have to write the inner Loop in the for Loop
              Eg:
              foreach ($params as $param)
              {
              $child=$param->childnodes;
              foreach ($child as $Child1)
              {
              echo $Child1->nodeName'<br>';
              echo $Child1->nodeValue'<br>';
              }
              }
              bye,


              deepu kumar <kumar_namburu@...> wrote:
              Hello,
              I used dom document for getting data from Xml file
              $doc = new DOMDocument();// creating object
              $doc->load('book.xml');// loading the xml file to read
              $params = $dom->getElementsByTagName('param');//returns nodes list as array

              foreach ($params as $param)
              {
              echo $param ->nodeName'<br>';
              echo $param ->nodeValue'<br>';
              }

              This is only for one level. if there are multi levels we have to write the inner Loop in the for Loop

              Eg:
              foreach ($params as $param)
              {

              foreach ($param as $Child)
              {
              echo $Child->nodeName'<br>';
              echo $Child->nodeValue'<br>';
              }
              }

              bye,

              dhana_1706 <dhana_1706@...> wrote:

              Hi,

              kindly anyone tell me how to read the XML file tag by tag?

              Thank u,
              dhana

              ---------------------------------
              Did you know? You can CHAT without downloading messenger. Click here

              [Non-text portions of this message have been removed]






              ---------------------------------
              5, 50, 500, 5000 - Store N number of mails in your inbox. Click here.

              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.