-
Notifications
You must be signed in to change notification settings - Fork 20
SimpleXML Migration
Thomas Weinert edited this page Dec 21, 2016
·
8 revisions
If you worked with SimpleXML before the following examples should help you to understand FluentDOM. Like SimpleXML, FluentDOM uses PHP language features and interfaces to provide an easier and more compact syntax. Unlike SimpleXML, FluentDOM tries not to hide DOM, but to extend it. PHP itself implements DOM Level 2, FluentDOM adds DOM Level 3 methods.
The complete source of the following examples can be found in the repository: [https://github.com/FluentDOM/FluentDOM/tree/master/examples/SimpleXML%20Migration].
FluentDOM::load() returns an extended DOM document.
$element = simplexml_load_string($string);
echo $element->saveXML();$element = simplexml_load_file($file);
echo $element->saveXML();$document = FluentDOM::load($string);
echo $document->saveXML();$document = FluentDOM::load($file, 'xml', [FluentDOM\Loader\Options::IS_FILE => TRUE]);
echo $document->saveXML();$document = FluentDOM::load('<div/>', 'html');
echo $document->saveHTML();$document = FluentDOM::load('{"foo": "bar"}', 'json');
echo $document->saveXML();- Home
- Getting Started
- Tasks
- Plugins
- Functions
- Lists
- Creator (5.1)
- CSS Selectors
- Convertors
- Loaders
- Serializers (5.1)
- Transformers (5.1)
- Extended DOM
- XMLReader (6.1)
- XMLWriter (6.1)
- Interfaces