Difference between XML DOM functions in PHP 4 and PHP 5

by Rekha 2009-12-09 12:13:04

The following are the difference between XML DOM functions in PHP 4 and PHP 5.

1)Create new XML document

PHP 4: domxml_new_doc('1.0');
PHP 5: new DomDocument('1.0');

2)create element

PHP 4:$doc->create_element('root');
PHP 5:$doc->createElement('root');

3)Append child

PHP 4:$doc->append_child($s);
PHP 5:$doc->appendChild($s);

4)Create text node

PHP 4:$doc->create_text_node($fieldvalue);
PHP 5:$doc->createTextNode($fieldvalue);

5)Set Attribute

PHP 4:$child->set_attribute('attr1', 'attrval1');
PHP 5:$child->setAttribute('attr1', 'attrval1');

6)Get completed XML document

PHP 4:$doc->dump_mem(true);
PHP 5:$doc->saveXML();

Tagged in:

1869
like
0
dislike
0
mail
flag

You must LOGIN to add comments