It's free and you have access to premium codes!
Welcome back! Please login to your account.
Don't worry, we'll send you a message to help you to recover your acount.
Please check your email for instructions to activate your account.
Written by 20 November 2012
This is a simple script to parse an XML file. It reads data from the file and insert them into table. the left column of the table is XML tags and the right one is their values. A sample XML is in attachment.
<!-- this script is provided by https://www.phpfreecode.com coded by: Kerixa Inc. -->
<!-- This Script is from www.phpfreecpde.com, Coded by: Kerixa Inc-->
<table align="center" style="width: 458px; font-family: 'Times New Roman', Times, serif; height: 87px; border-width: 0px">
<?php
$xmlfile = 'test.xml';
$xmlparser = xml_parser_create();
$fp = fopen($xmlfile, 'r');
$xmldata = fread($fp, 4096);
xml_parse_into_struct($xmlparser,$xmldata,$values);
xml_parser_free($xmlparser);
foreach($values as $m){
if ($m['type']=='open'||$m['type']=='complete' ){
echo('<tr style="background-color: #8BD4FF"><td style="text-align: left; width: 228px; font-size: 17pt; height: 29px; background-color: #CECEFF;">
<strong>'.$m['tag'].'</strong></td>
<td style="text-align: left; width: 228px; font-size: 17pt; height: 29px; background-color: #CECEFF;">'.$m['value'].
'</td></tr>');
}
}
?>
</table>
<div style="text-align: center">
<font face="Tahoma"><a target="_blank" href="http://www.phpfreecode.com/">
<span style="font-size: 8pt; text-decoration: none">PHP Free Code
</span></a></font></div><a target='_blank' href='https://www.phpfreecode.com' style='font-size: 8pt; text-decoration: none'>Php Best Codes</a>
Comments
Here you can leave us commments. Let us know what you think about this code tutorial!