Skip to content
Thomas Weinert edited this page Jul 29, 2014 · 1 revision

FluentDOM\XmlSerializable

Defines an object that can return its output as an XML fragment. The interface extends FluentDOM\Appendable. An class implementing this needs to implement appendTo() but you can use the trait XmlSerialize to implement getXml().

Usage

class Example implements \FluentDOM\XmlSerializable {

  use \FluentDOM\XmlSerialize;

  public function appendTo(\FluentDOM\Element $parent) {
    $parent->appendElement(
      'message',
      'Hello World!'
    );
  }
}
$example = new Example();
echo $example->getXml();
```

### Output

```xml
<message>Hello World!</message>
```
Clone this wiki locally