Page 1 of 1
DOM or SimpleXML
Posted: Fri May 02, 2008 1:31 pm
by kendall
Hey,
I'm a bit undecisive....
I want to use XML to store 'simple data' for feeding to a class. I have been looking through simple xml and seems that its is the preferred choice however I i note that the CDATA issue and this is going to have a big draw back for my development.
What is the better of the two php methods to use? Which function is more likely to be installed on hosting packages? What has been the work around for the CDATA issue with simple xml?
Re: DOM or SimpleXML
Posted: Fri May 02, 2008 11:38 pm
by alex.barylski
SimpleXML if you need basic manipulation and mostly read only, DOM if you need more control.
SimpleXML shouldn't have an issue with CDATA although I have encountered a few bugs which were annoying. If I recall it was nested UL produced weird results...I can't remember though.
SimpleXML is nice because its stored as an PHP array. DOM requires you to use the DOM methods and when your print_r to see your DOM you don't actually see anything because it uses an internal tree I assume anyways.
I would start with SimpleXML and move into DOM if you need it...much easier to get started with
Re: DOM or SimpleXML
Posted: Sat May 03, 2008 1:12 am
by Kieran Huggins
As someone who tried to love XML and failed, may I suggest a different format altogether?
Serialized data works nicely, as does JSON encoded data. There are also a few well understood registry patterns if you want to go the object route.
As a document format XML is just lovely, but as a generic storage container I find it restrictive and ambiguous at best.
Re: DOM or SimpleXML
Posted: Sat May 03, 2008 6:34 am
by kendall
Kieran Huggins,
hate it or love it the underdog is on top....I think xml is lovely i really love its portability usage...yeah parsing can be tricky...but its really light weight...
I have yet to venture into this JSON realm...
thanks for the advise guys...
Re: DOM or SimpleXML
Posted: Mon May 05, 2008 11:30 pm
by John Cartwright
Kieran++
Re: DOM or SimpleXML
Posted: Fri May 09, 2008 3:13 am
by Maugrim_The_Reaper
With the right tools, JSON and XML are interchangeable... You could actually make your life easier if you the pick the easiest one to handle and convert back and forth to the other only when required.
That said, I'm an XML animal

. I prefer to work with it where possible, but there's no escaping the clarity of JSON anymore.