0

Background: So i'm writing a web-service style web application as a way to increase my knowledge of how PHP and XML work together. I want to eventually take that XML data and use it in a mobile phone application but that's a different issue. I can connect to the data, pull, and process all the information with PHP and I've managed to get it exporting to CSV. I want to now begin to push that data out in XML.

Question: What is the (a) recommended way to work with XML in PHP?

References: PHP Manual, XML Portion

Mr. Lost IT Guy
  • 137
  • 2
  • 12
  • 3
    I like [SimpleXML](http://www.php.net/manual/en/book.simplexml.php). – gen_Eric Mar 22 '11 at 21:04
  • Yep, SimpleXML gets stuff done. Here's another SO Q you might get some info from: http://stackoverflow.com/questions/2892313/alternatives-to-simplexml-for-parsing-xml-files-with-php, also, depending on where your PHP/XML goes from there XSLT can be very handy. – danjah Mar 22 '11 at 21:09
  • Me too, I almost always use SimpleXML, but you can check out the PEAR libraries: [link](http://pear.php.net/packages.php?catpid=22&catname=XML) – AJJ Mar 22 '11 at 21:10
  • 1
    possible duplicate of [Best XML Parser for PHP](http://stackoverflow.com/questions/188414/best-xml-parser-for-php) – Gordon Mar 22 '11 at 21:13
  • And since you said Webservices, you might want to extend your question to include http://www.php.net/manual/en/refs.webservice.php – Gordon Mar 22 '11 at 21:17
  • Depending on your requirements, I'd suggest taking a look at [JSON-RPC](http://en.wikipedia.org/wiki/JSON-RPC) since it's far easier to work with than XML in just about every language... – ircmaxell Mar 22 '11 at 21:18

1 Answers1

3

I suggest using simple XML which is way easier to handle xml operations.

Nick Weaver
  • 47,228
  • 12
  • 98
  • 108
  • That depends on the XML to be handled. Just because it's called SimpleXml doesnt mean it is the simplest for handling XML. – Gordon Mar 22 '11 at 21:14
  • 1
    In fact, I typically find SimpleXML harder to use than Dom. Sure, it's less verbose, but it's also less explicit and requires intimate knowledge of the behaviors to follow. I'd suggest DomDocument instead... – ircmaxell Mar 22 '11 at 21:19
  • As I said: I suggest. I've tried several ways work with xml and I found simpleXML very convenient. – Nick Weaver Mar 22 '11 at 21:23