tags:

views:

114

answers:

2

SimpleXML seems ok, but one thing that's annoying is whenever assigning/storing a value you have to typecast it - this really is a tad annoying. DOM is ok but I really like the flexibility of XPath, sometimes DOM can be a tad too much writing-wise.

I really like the selector implementation in jQuery, and the flexibility. I came across http://jquery.hohli.com/ while googling but just wanted to see if anyone had recommendations before I try it out.

+1  A: 

I usually use SimpleXML - it does support XPath with SimpleXMLElement::xpath.

Maybe a bit more information on what you're trying to do... are you reading a whole XML file into a data structure, or just trying to grab one or two values from it?

Greg
It varies - SimpleXML is nice when you're doing subtle things but sometimes I do have to modify the structure a bit and that's when I get frustrated by all the typecasting that's needed.
meder
+3  A: 

I use SimpleXmlElement for reading and DOMDocument for creating XML. You can also look at the XMLReader as in PHP 5.1. This is a fast way to "walktrough" an XML document. PHP also provides event-based XML parsing (SAX).

If you have a good combination of read/write actions you maybe should extend the SimpleXmlElement or DOMDocument classes or write a few helper functions which do all that casting work for you.

Philippe Gerber
I was thinking about extending SimpleXMLElement - I think I'll go ahead with that.
meder