By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,269 Members | 1,509 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

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

P: 4
Hi,

I want to know, How we will read the XML File Comments using PHP Code.
Thaks in advance.
Mar 13 '07 #1
Share this Question
Share on Google+
4 Replies


ronverdonk
Expert 2.5K+
P: 4,258
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:
Mar 13 '07 #2

P: 4
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.
Mar 13 '07 #3

ronverdonk
Expert 2.5K+
P: 4,258
Show the code you are using to read the xml data.

And display it within php or code tags!!

Ronald :cool:
Mar 13 '07 #4

P: 4
XML File:
[XML]
File Name: 'hbwas51_proc_54.xml'

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

$rows = $doc->getElementsByTagName("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 -->
Mar 14 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.