Jump to content

xml file to print to help in html table data.


turk182

Recommended Posts

Hi, I need your help.
 
xml file:
 
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<STOKLAR>
<STOK Stok_Kod="" Stok_Ad="">
<OZELLIKLER>
<OZELLIK></OZELLIK>
<DEGER></DEGER>
<OZELLIK></OZELLIK>
<DEGER></DEGER>
<OZELLIK></OZELLIK>
<DEGER></DEGER>
<OZELLIK></OZELLIK>
<DEGER></DEGER>
<OZELLIK></OZELLIK>
<DEGER></DEGER>
<OZELLIK></OZELLIK>
<DEGER></DEGER>
</OZELLIKLER>
</STOK>
</STOKLAR>
</ROOT>
 
--------------------------------------------
 
This way you can print:
 
<?php

$root = simplexml_load_file("exaproperties.ashx");

foreach ($root->STOKLAR->STOK as $stok) {
foreach ($stok->OZELLIKLER as $ozellikler) {
for ($i=0;$i <=count($ozellikler);$i++){ 

echo '<table>' ;
                     echo '<tr>' ;
                     echo '<td ALIGN="left" VALIGN="TOP" BGCOLOR="#FFFFFF">'.$ozellikler->OZELLIK[$i].'</td>';
                     echo '<td ALIGN="left" VALIGN="TOP" BGCOLOR="#FFFFFF">:</td>';
                     echo '<td ALIGN="left" VALIGN="TOP" BGCOLOR="#FFFFFF">'.$ozellikler->DEGER[$i].'</td>';
                     echo '</tr>' ;        
                     echo '</table>' ;
                     $i++;

        }
        }
}

?>

01.png

----------------------------------------------------
However, only the html table is added to the database, data is not added into HTML table cells.
 
$xmlData = simplexml_load_file($xml_directory.$this->code."/exaproperties.ashx");
foreach ($xmlData->STOKLAR->children() as $STOK) {
         foreach ($STOK->children() as $OZELLIKLER => $data) {
    for ($i=0;$i <=count($data);$i++){
    
                     $tablo = '';
                     $tablo.= '<table>' ;
                     $tablo.= '<tr>' ;
                     $tablo = '<td ALIGN="left" VALIGN="TOP" BGCOLOR="#FFFFFF">'.$data->OZELLIK[$i].'</td>';
                     $tablo.= '<td ALIGN="left" VALIGN="TOP" BGCOLOR="#FFFFFF">::</td>';
                     $tablo.= '<td ALIGN="left" VALIGN="TOP" BGCOLOR="#FFFFFF">'.$data->DEGER[$i].'</td>';
                     $tablo.= '</tr>' ;        
                     $tablo.= '</table>' ;
        }
    }
}

02.png

----------------------------------------
If the support I rejoice.(Sorry for bad english)

Archived

This topic is now archived and is closed to further replies.

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