Reading Comment Lines(<!-- 2007 -->) from XML File using PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manickkarthik
    New Member
    • Mar 2007
    • 4

    Reading Comment Lines(<!-- 2007 -->) from XML File using PHP

    Hi,

    I want to know, How we will read the XML File Comments using PHP Code.
    Thaks in advance.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Originally posted by manickkarthik
    Hi,

    I want to know, How we will read the XML File Comments using PHP Code.
    Thaks in advance.
    Your problem is not clear to me. Are you actually reading the xml file and want to skip the comment lines? What is the process you are following to read this file?

    Ronald :cool:

    Comment

    • manickkarthik
      New Member
      • Mar 2007
      • 4

      #3
      Thanks for your reply. I was reading all other tag data's from XML file, but i can't read the comment line data's. I want to read comment line data's also and diaplay in browser using php code.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Show the code you are using to read the xml data.

        And display it within php or code tags!!

        Ronald :cool:

        Comment

        • manickkarthik
          New Member
          • Mar 2007
          • 4

          #5
          XML File:
          [XML]
          File Name: 'hbwas51_proc_5 4.xml'

          <database>
          <!-- 2006-12-27 15:45:00 IST / 1167214500 --> <row><v> 3.4102666667e+0 2 </v></row>
          <!-- 2006-12-27 15:50:00 IST / 1167214800 --> <row><v> 3.4100000000e+0 2 </v></row>
          <!-- 2006-12-27 15:55:00 IST / 1167215100 --> <row><v> 3.4100000000e+0 2 </v></row>
          <!-- 2006-12-27 16:00:00 IST / 1167215400 --> <row><v> 3.4178333333e+0 2 </v></row>
          <!-- 2006-12-27 16:05:00 IST / 1167215700 --> <row><v> 3.4101333333e+0 2 </v></row>
          <!-- 2006-12-27 16:10:00 IST / 1167216000 --> <row><v> 3.5140000000e+0 2 </v></row>
          <!-- 2006-12-27 16:15:00 IST / 1167216300 --> <row><v> 3.5140000000e+0 2 </v></row>
          <!-- 2006-12-27 16:20:00 IST / 1167216600 --> <row><v> 3.5678666667e+0 2 </v></row>
          <!-- 2006-12-27 16:25:00 IST / 1167216900 --> <row><v> 3.5581333333e+0 2 </v></row>
          <!-- 2006-12-27 16:30:00 IST / 1167217200 --> <row><v> 3.5581333333e+0 2 </v></row>
          <!-- 2006-12-27 16:35:00 IST / 1167217500 --> <row><v> 3.6214000000e+0 2 </v></row>
          <!-- 2006-12-27 16:40:00 IST / 1167217800 --> <row><v> 3.6214000000e+0 2 </v></row>
          <!-- 2006-12-27 16:45:00 IST / 1167218100 --> <row><v> 3.5512000000e+0 2 </v></row>
          <!-- 2006-12-27 16:50:00 IST / 1167218400 --> <row><v> 3.5500000000e+0 2 </v></row>.
          </database>

          [/XML]


          The below code read the row tag values from the above xml file:

          [php]
          <?php

          $doc = new DOMDocument();

          $doc->load( 'hbwas51_proc_5 4.xml' );

          $rows = $doc->getElementsByT agName("row");
          foreach($rows as $node) {
          print $node->textContent . " ";
          }
          [/php]

          Now i want to read the comment lines from the above XML file
          example comment lines:
          <!-- 2006-12-27 15:45:00 IST / 1167214500 -->

          Comment

          Working...