Skip to content

Element AppendElement

Thomas Weinert edited this page Aug 1, 2014 · 5 revisions

FluentDOM\Element::appendElement()

FluentDOM\Element appendElement(
  string $name [ , string $content = '' [ , array $attributes = NULL ]]
)

A shortcut to create, configure an append an element node.

Usage

$dom = new FluentDOM\Document();
$dom->appendChild($dom->createElement('div'));
$dom->documentElement->appendElement(
  'span', 'Hello World!', ['class' => 'message']
);

echo $dom->saveXML();

Output

<?xml version="1.0" encoding="UTF-8"?>
<div><span class="message">Hello World!</span></div>
Clone this wiki locally