| 
	
 | 
 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] 
 |