Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

italiano40

macrumors 65816
Original poster
Oct 7, 2007
1,080
0
NY
a couple things
one i just start writing in php, but i know html, css, java, C++, Cocoa
and i want to know what is the best way to pase
a xml document, also in php is their something like null
i couldn't find anything about it
 
For parsing XML I generally treat it as a DOM document:
PHP:
$doc = new DomDocument();
$doc->load("your.xml");
$tags = $doc->getElementsByTagName("tag");

There's also Simple XML:
PHP:
$doc = simplexml_load_file('your.xml');

PHP null.
 
ok, it i wanted to go thru each tag which one would you recommend the simple xml or treat as dom?
 
ok, it i wanted to go thru each tag which one would you recommend the simple xml or treat as dom?

I prefer DOM because I work with JavaScript a bit so I'm use to thinking that way. Simple XML has some power over DOM in some instances though. I suggest doing some reading on articles that compare the two approaches so you can decide which will best suit the work your doing.

One suggested reading: http://www.ibm.com/developerworks/library/x-xmlphp3.html
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.