I am trying to convert a XML into JSON. I am converting XML into a Hashref and then using JSON::Any to JSON. I am struck in the first part i.e. XML to HashRef. My source XML
I tried with XML::Simple<Publisher> <UniqueDOI>978-3-642-123456</UniqueDOI> <ChapterInfo ChapterType="OriginalPaper"> <Title Language="En">Is Light Blue (<Emphasis Type="Italic">azzurr +o</Emphasis>) Color Name Universal in the Italian Language?</Title> </ChapterInfo> </Publisher>
Using XML::LibXML::Simpleuse XML::Simple; use Data::Dumper; my $XMLRef = XMLin('new.xml'); print Dumper $XMLRef;
Using XML::Twiguse XML::LibXML::Simple (); use Data::Dumper; my $xs = XML::LibXML::Simple->new(%options); my $XMLRef = $xs->XMLin('new.xml'); print Dumper $XMLRef;
use XML::Twig; use Data::Dumper; my $twig=XML::Twig->new(); my $XMLRef = $twig->parsefile( 'new.xml' )->simplify(); print Dumper $XMLRef;
Update: All the above scripts are NOT properly converting the child "Emphasis". The error part of the dump is more or less similar to
Is it possible to do like (leave specific tags as it is)'ChapterTitle' => { 'Emphasis' => { 'Type' => 'Italic', 'content' => 'azzurro }, 'Language' => 'En', 'content' => [ 'Is Light Blue (', ') Color Name Univeral in the Italian Language?' ] },
'ChapterTitle' => { 'Language' => 'En', 'content' => [ 'Is Light Blue (<Emphasis Type="Italic">azzurro</Emphasis>) Co +lor Name Univeral in the Italian Language?' ] },
I appreciate any pointers in this regard.
Regards DominicIn reply to XML to HashRef and then to JSON by dominic01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |