-3

Possible Duplicate:
How to parse HTML with PHP?
Get MySQL database output via PHP to XML

I have some tables in MySQL.... Can I use PHP to create a .xml file on my website that will neatly contain the information from my MySQL database?

On a side note if I am retrieving xml information in action script 2.0 do I HAVE to retrieve it from a .xml file or can I have a .php file that creates an open and close tag on the page and then creates an xml table on the .php page?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195

2 Answers2

1

As an answer to your side note:
Yes you can - thats the normal way to do it.
AS does not even know if it was a file or created on the fly - it just receives the data and if it is valid XML it should work...

Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
1

you can create XML in PHP and you can save it as file or echo as XML string , you can use below sample codes

        $xml = new DOMDocument('1.0', 'iso-8859-1');

        $rootNode = $xml->createElement('xmlrootnode');
        $rootNode = $xml->appendChild($rootNode);

        foreach( $resultArr as $r )  {

            $sDateArr = explode( ' ', $r['start_time'] );
            $sRootN = $xml->createElement('date');
            $sRootN = $rootNode->appendChild($sRootN);
            $sRootN->setAttribute('value', $sDateArr[0]);

            //Id field
            $idN = $xml->createElement('id');
            $idN = $sRootN->appendChild($idN);

            $idT = $xml->createTextNode(htmlentities($r['id']));
            $idN->appendChild($idT);
        }
        //$xml->save($xml);
        //header('Content-type: text/xml');
        //echo $xmlStr = $xml->saveXML();
        $xmlStr = isset($xml) ? htmlspecialchars($xml->saveXML()) : '';
Robin Michael Poothurai
  • 5,444
  • 7
  • 23
  • 36