LibreCat / Catmandu-XML

Catmandu modules for working with XML data
https://metacpan.org/module/Catmandu::XML
Other
4 stars 3 forks source link

xml_write() should support setting the root element name #22

Closed phochste closed 2 years ago

phochste commented 6 years ago

In the current version of xml_write the root element is always called <root>.

xml_write(marc)

If marc contains something like:

marc:
 record:
   controlfield: ...
   datafileld: ....

The fix will currently result in:

<root><record><controlfield>...</controlfield><datafield>...</datafield></root>

which need to be processed regex search/replace to create the correct '' root element.

nichtich commented 2 years ago

The content to be written is expected to follow XML::Struct, so the record should contain something like:

marc:
- record
- - - controlfield
    - ...
  - - datafield
    - ...

I guess you were looking for the reverse of xml_simple like implemented as [XMLout in XML::Simple](https://metacpan.org/pod/XML::Simple#XMLout()). I move this request to #24.