xmlsimple

How do I convert Data::Dumper output back into a Perl data structure?

Hi all! I was wondering if you could shed some lights regarding the code I've been doing for a couple of days. I've been trying to convert a Perl-parsed hash back to XML using the XMLout() and XMLin() method and it has been quite successful with this format. #!/usr/bin/perl -w use strict; # use module use IO::File; use XML::Simple; u...

How do I produce XML with Perl's XML::Simple?

I am just trying to create the XML use XML::Simple; my %element = ( "a" => "10" , "b" => "20" ,); my $xs = new XML::Simple(); my $ref = $xs->XMLin(%element); my $xml = $xs->XMLout($ref); print $xml; What is wrong on this code ? ( This is got Resolved ) use XML::Simple; my %element = ( "a" => "10" , ...

How do I disable subtag sorting in Perl's XML::Simple?

I just want to find the way of disable the sort operation in XML::Simple For example: #!/usr/bin/perl use strict; use warnings; use XML::Simple; my %my_xml = ( NAME => [ 'test' ], EMAIL => [ '[email protected]' ], ID => 12, ); my $xs = XML::Simple->new; print $xs->XMLout(\%my_xml, RootName => "datas", NoSort => 1); ...

Can I use XML::Simple with an in-memory string, rather than a file?

XML::Simple documentation says to initiate the data structure with an XML file, using XMLin('[FILENAME]') ... but I have an in-memory string. Can I use it directly, or do I need to save it to the filesystem and then load it into XMLin? ...

How can I save XML data to a file with XML::Simple?

I'm using XML::Simple package to import an XML file and change a few properties of some of the child tags. The change is visible when the data is dumped with: print Dumper($data); But how can I write this edited data into a new XML file? I did go through the CPAN page, but some code regarding this would really help. ...

How can I replace the <opt> tag in XML::Simple with the original tag name?

I'm using XML::Simple to edit an XML file. After which the updated data is sent to a new XML file. But this procedure produces <opt></opt> tag to be added and the original parent tag is lost. I want to replace <opt> with the original tag name. How do I do that? ...

Does XML::Simple maintain order when using arrays?

I'm using XML::Simple to parse an XML file which I then want to use to write an output file in a very specific format. Thus, the output order is important. As I understand it, when the XML is converted to the perl hashref the order is lost (because perl hashes have no order). But what about when an array is used by XML::Simple. For ex...

XML::Simple encoding problem

Hi, I have an xml-file I want to parse: <?xml version="1.0" encoding="UTF-8" ?> <tag>û</tag> It's perfectly parsed by firefox. But XML::Simple corrupts some data. I have a perl-program like this: my $content = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; $content .= "<tag>\x{c3}\x{bb}</tag>\n"; print "input:\n$content\n"; my $...