Reads an XML file, whose path is set in the options, and outputs it as a \DOMDocument.
Requires the dom PHP extension.
- Service:
CleverAge\ProcessBundle\Task\File\Xml\XmlReaderTask
Input is ignored (a warning is logged if an input is given).
\DOMDocument: document loaded from the file content with
DOMDocument::loadXML.
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
file_path |
string |
X | Path of the file to read | |
mode |
string |
rb |
File open mode (see fopen mode parameter) |
# Task configuration level
read_xml:
service: '@CleverAge\ProcessBundle\Task\File\Xml\XmlReaderTask'
options:
file_path: '%kernel.project_dir%/var/data/file.xml'
outputs: [transform]- An empty file throws an
\UnexpectedValueException. - An invalid XML content (not well-formed, undefined namespace prefix...) throws an
\UnexpectedValueExceptionwhose message contains the libxml error(s) with their line and column. libxml warnings are tolerated. The libxml internal errors setting is restored after loading.