Jump to content

PHP XML DOM Tutorial


trinistorm

Recommended Posts

I am reading

New Riders Publishing: Php and Xml
and decided to check out the tutorial on PHP DOM. Now the book suggests PHP is likely to change DOM support after version 4.1.1. and i noticed differences in their approaches to the W3school'sTheir code is :
<?php // create a DomDocument object $doc = xmldoc(); // root node $fruit = $doc->root(); ?>

W3schools uses the

$xmldoc = new DOMDocument();

class.Which method is cleaner to use?

Link to comment
Share on other sites

There is no native xmldoc() function in PHP, so it is probably a factory function defined within the book. While there is no advantage if all it does is return an instance of DOMDocument, it may also set properties or otherwise modify the object before returning it, which may be useful.

Link to comment
Share on other sites

The book is old. PHP is now at version 5, and it doesn't use any of the things mentioned in the book.PHP4 used the XML DOM extension, but PHP5 has a DOM extension that's built in, and is fully object oriented. That's what W3Schools teaches, and that's what you should learn to use... not that pseudo DOM crap from PHP4.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...