/** * @param DOMNode $node * @param ReferenceTable $table */ public function next(DOMNode $node, ReferenceTable &$table) { foreach ($node->childNodes as $child) { /* * Text */ if ($child instanceof DOMTEXT) { $table->appendContentByNode($child); } elseif ($child instanceof DOMElement) { /* * Attributes */ foreach ($child->attributes as $attribute) { $parser = AttributeParserFactory::create($attribute->name, $this->sheet); if ($parser) { $parser->parse($attribute, $table); } } // Get the element parser based on the node name $parser = ElementParserFactory::create($child->nodeName, $this->sheet); // It's possible a parser does not exist // That means it's probably not very interesting // to parse that element if ($parser) { $parser->parse($child, $table); } else { $this->next($child, $table); } } } }
public function test_append_content_by_node() { $node = new \DOMElement('name', 'value'); $this->table->appendContentByNode($node); $this->assertEquals('value', $this->table->getContent()); }