PHP XML parser tutorial

Does anybody know a good tutorial about this?

oh, i never thought of that, probably cuz im lazy. I’ll try that out. Thanks!

well… there are two main ways of parsing XML in PHP:

DOM: This builds up a tree of all the elements in the document. It is very similar to the way Flash uses XML.

SAX:This parses elements one by one.

The DOM approach is good because there are many tutorials for other mediums(like Flash) that use this approach, and they should be intercompatible with PHP’s method.

The DOM extension is still experimental(http://uk2.php.net/manual/en/ref.domxml.php), whereas the SAX extension is mature and stable.

So it all comes down to personal choice I guess. I’d go with the DOM approach seeing as then you can use Sen’s XML tute and a lot of other ones as well, and the extension should become more stable as time goes on :slight_smile:

Oh, and I already know Flash XML, so I assume it would be easy to learn as well.

nj: Is expat the same as SAX? If not then thats another way to parse…

edit: Yeah I’m prety sure that expat is different. Like njs said DOM is very similar to the Flash way of handing XML so if you are looking to incorporate Flash at some point DOM is probably the way to go… I like EXPAT but I have never really dealt with SAX so my judgement is kind of biased. Your best bet is to google for “php xml parse tutorial”

Umm, what in the world is EXPAT and SAX??? :h:

different ways of parsing XML…

most of the tutorials that I found out there for parsing XML in PHP have been pretty advanced… can you give me some more information about what you want to do and I might be able to write up a quick easy beginner tutorial for it…

jubba, i think expat and sax refer to the same thing :slight_smile:

but on the php site the SAX handlers are under the XSLT section and the EXPAT functions are under the XML section…

thats why I think they are different…

EXPAT: http://us4.php.net/xml

SAX: http://us2.php.net/xslt

edit: upon further reading I think that SAX uses EXPAT but they are not the same thing…

makes sense :slight_smile:

well, i just wanted to know how to use it in case I needed it. Didn’t know there were complications in it. But anyways, all I want is a simple parsing and using the information in XML for different purposes, just like one would for Flash. That’s all

Whats the full form of SAX and EXPAT anyways?

SAX mean “Simple API for XML”, I’m not quite sure about EXPAT, google it up! :slight_smile:

oh, its cool man. Take your time. Do it after your finals and good luck for it!