Are there any modules in CPAN to convert YAML lists to well formed XML?
From YAML:
- fruits:
- apple
- pear
- orange
To XML:
<fruits>
<apple />
<pear />
<orange />
</fruits>
use strictures;
use YAML "Load";
use XML::Simple "XMLout";
my $data = Load(do{ local $/; <DATA> });
print XMLout( $data, XMLDecl => 1 );
__DATA__
---
- fruits:
- apple
- pear
- orange
There might be a combination of options for XMLout
that will DWYW and you may need to jigger your data structure to get the root name you want, etc. You'll note from the dizzying array of options that serializing and marshalling XML to other data formats is decidedly not simple. Reading: XML::Simple and YAML.
No there is no CPAN module for that. there are CPAN modules to read YAML and there are modules to write XML. The data transfer will be perl data structure.
The question is what schema your XML should be in, and there are many different XML modules, so there is also no one perfect answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With