Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 1.57 KB

xml_writer_task.md

File metadata and controls

47 lines (34 loc) · 1.57 KB

XmlWriterTask

Writes the \DOMDocument received as input to an XML file, whose path is set in the options. Requires the dom PHP extension.

Task reference

  • Service: CleverAge\ProcessBundle\Task\File\Xml\XmlWriterTask
  • Code: xml_writer (task: xml_writer)

Accepted inputs

\DOMDocument: document to dump with DOMDocument::saveXML. An UnexpectedValueException is thrown for any other type.

Possible outputs

string: path of the written file (value of the file_path option).

Options

Code Type Required Default Description
file_path string X Path of the file to write to
mode string wb File open mode (see fopen mode parameter)

Examples

# Task configuration level
write_xml:
  task: xml_writer
  options:
    file_path: '%kernel.project_dir%/var/data/file.xml'

Notes

  • The file is opened on each execution: with the default wb mode, each input overwrites the file.
  • If the XML content cannot be generated (\DOMDocument::saveXML() fails) or written, a RuntimeException is thrown.