0
<?xml>
<table>
    <row>
        <columnA>ValueA</columnA>
        <columnB>ValueB</columnB>
        <columnC>ValueC</columnC>
        <columnD>ValueD</columnD>
        <columnE>ValueE</columnE>
    </row>
    <row>
        <columnA>ValueA</columnA>
        <columnB>ValueB</columnB>
        <columnC>ValueC</columnC>
        <columnD>ValueD</columnD>
        <columnE>ValueE</columnE>
    </row>
...
</table>
MacMac
  • 34,294
  • 55
  • 151
  • 222
CRISHK Corporation
  • 2,948
  • 6
  • 37
  • 52
  • you can likely adapt the [code shown here](http://stackoverflow.com/questions/2207599/multidimensional-array-iteration/2207739#2207739) – Gordon Oct 14 '10 at 14:20

3 Answers3

2

Some quick Googling reveals this as your best option: http://www.tonymarston.net/php-mysql/dom.html

VoteyDisciple
  • 37,319
  • 5
  • 97
  • 97
0

You could either use...

htmlentities($table, ENT_QUOTES);

Or you could use CDATA...

<![CDATA[
<table>
    <row>
        <columnA>ValueA</columnA>
        <columnB>ValueB</columnB>
        <columnC>ValueC</columnC>
        <columnD>ValueD</columnD>
        <columnE>ValueE</columnE>
    </row>
    <row>
        <columnA>ValueA</columnA>
        <columnB>ValueB</columnB>
        <columnC>ValueC</columnC>
        <columnD>ValueD</columnD>
        <columnE>ValueE</columnE>
    </row>
...
</table>
]]>
Fenton
  • 241,084
  • 71
  • 387
  • 401
  • I'm looking for a function like json_encode that converts an array to JSON format, but in this case to XML – CRISHK Corporation Oct 14 '10 at 13:52
  • There isn't a built-in function for that, but there custom functions available... like this one... http://snipplr.com/view/3491/convert-php-array-to-xml-or-simple-xml-object-if-you-wish/ – Fenton Oct 15 '10 at 06:54
0

I prefer using MDB2-Schema PEAR class to store SQL table structure in XML files. http://pear.php.net/manual/en/package.database.mdb2-schema.dump.php

Māris Kiseļovs
  • 16,957
  • 5
  • 41
  • 48