Quickstart: DOM Tree building

Posted on January 15, 2007. Filed under: Quick Start |

1. Document object:

$dom = new DomDocument;

2 . Element:

$docElement = $dom->createElement(‘root’) ;

$dom->appendChild($docElement) ;

3. Set attribute:

$docElement->setAttribute(‘attrname’, ‘attrvalue’);

4. Element with textual content:

$para = $dom->createElement(‘p’, ‘Lorem ipsum dolor…’) ;

5. Append child:

$docElement->appendChild($para);

6. Import node:

$import = $dom->importNode($foreignNode, true);

If the second argument is set to true the subtree under $foreignNode will be imported, too. Now append the node named $import (see 5).


Read Full Post | Make a Comment ( None so far )

Recently on notes171...

Quickstart: Zend_Session

Posted on January 14, 2007. Filed under: Quick Start, Zend Framework |

SQL Joins

Posted on January 12, 2007. Filed under: SQL |

Zend Framework Application Example

Posted on December 6, 2006. Filed under: Zend Framework |

Count rows with Zend_Db

Posted on December 5, 2006. Filed under: Zend Framework |

  • Bookmarks

Liked it here?
Why not try sites on the blogroll...

Follow

Get every new post delivered to your Inbox.