You are here: DomDocument: setting attributes to a new node « PHP Programming Language « IT news, forums, messages
DomDocument: setting attributes to a new node

Posted by Sebastian Araya on 11/15/05 22:35

Hello,


I'm trying to create a single function to append new nodes to a
DOMDocument object:

public function addElement( $element, $name, $value = '', $attrs = Null
)
{
if( !( $created = $this->createElement( $name, $value ) ) )
throw new Exception( 'Could not create a new node ' );

if( !( $child = $element->appendChild( $child ) ) )
throw new Exception( 'Could not append a new node ' );

// Process and attachs the new attributes from array $attrs if
any...
// if( $attrs )
// foreach( $attrs as $attribute => $value )
// ...
}

So far, so good. Now I want to set attributes and its values of the
recent created node (playing with createAttribute() and setAttribute(),
but I can't get the DOMElement from the new child DOMNode. Is it
possible without issuing getElementsByTagName() or getElementById() ??

Is another easy way -using DomDocument object- to create a new
element (such <table width="50%" border="0">...</table>) which has its
attributes and its values ??

Thanks in advance,


Sebastián Araya

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация