Alex Cook
Alex Cook

Reputation: 273

Best Practice for Exporting an App's Data to XML via PHP/MySQL?

I have a business app and I want to give my users the ability to export their data at anytime.

I'm aware that I can write an XML file semi-manually by doing something like this: http://www.kirupa.com/web/mysql_xml_php.htm

But, I thought I'd ask if this is the best practice? Or is there some framework I can use to do this more easily/quickly? Maybe there isn't - it won't be too hard to do it the above way.

Also, less importantly - XML is the best format to export to, right?

Thanks in advance.

Upvotes: 2

Views: 1046

Answers (4)

ajreal
ajreal

Reputation: 47321

there is no reason to reinvent the wheel, mysql already support selecting result into xml format since 5.1

XML is the best format to export to, right?

too subjective, some said yes, some said no ...

Upvotes: 1

John Kramlich
John Kramlich

Reputation: 2260

The best format to export your data largely depends on what kind of data you are exporting. For some datasets, a simple export to Comma Separated Value (CSV) files will be sufficient. If your data is more complex, there is a PEAR package that will serialize PHP values into XML objects.

This tutorial will show you how to use the various PEAR packages to take your existing data in PHP and convert it relatively easily to well structured XML:

http://articles.sitepoint.com/article/xml-php-pear-xml_serializer

I would definitely recommend XML as an option for exporting your data as there are a vast number of tools and technologies that interact well with XML; XQuery, XSLT, etc.

Upvotes: 1

makes
makes

Reputation: 6548

I recommend having a look at the PEAR package XML_Query2XML.

Upvotes: 1

lando
lando

Reputation: 141

I would you php's DomDocument class. its really easy to use >> http://php.net/manual/en/class.domdocument.php

Upvotes: 0

Related Questions