Jump to content

PHP: Convert html table to XML


lilmer

Recommended Posts

I have a table that has a row and column with different style and colspan etc.

 

Does anyone know how to convert it HTML to XML file with the designated style Using PHP. Cause I going to convert it the xml to xls also.

 

<table>
<tbody>
 <tr>
   <td>1</td>
   <td>2</td>
   <td>3</td>
   <td>4</td>
   <td>5</td>
</tr>
 <tr>
   <td>1</td>
   <td>2</td>
   <td colspan='2'>34</td>
   <td>5</td>
</tr>
 <tr>
   <td stye='font-weight:bold'>BOLD</td>
   <td stye='font-style:underline'>underline</td>
   <td stye='font-stye:arial'>Italic</td>
   <td stye='font-familty:aria'>Arial</td>
<td stye='background-color:Blue'>Arial</td>
</tr>
</tbody>
</table>

Link to comment
https://forums.phpfreaks.com/topic/274672-php-convert-html-table-to-xml/
Share on other sites

XML does not contain styles. Embed the data in the XML any way you see fit, then write the XSLT so that it uses the right styles. Consider all the information the XSLT will need to use to output the right HTML: the raw text, colspans, CSS attributes and values...

@Barand

 

Yes, my goal is to create a excel file and can be edit also on html web page, like google spreadsheet. I can already generate a .xls file to my web page and its content using phpexcelreader. My problem now is to save the existing file as I change some content on the html page. Do you think its a good idea to save the html to xml and to .xls?? do you think it will work?

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.