XML::Hash::LX - Convert hash to xml: not the expected output
I'm trying to convert a hash to a XML-string with this module XML::Hash::LX but I get only the first hash-key. Can someone tell me, how to ge开发者_JAVA百科t the whole hash?
#!/usr/bin/env perl
use warnings;
use 5.012;
use XML::Hash::LX;
my $hash = { one => 1, two => 2, three => 3, four => 4 };
my $str = hash2xml( $hash );
print $str;
# Output:
# <?xml version="1.0" encoding="utf-8"?>
# <three>3</three>
You lack a root element.
hash2xml { numbers => { one => 1, two => 2, three => 3, four => 4 } }
<?xml version="1.0" encoding="utf-8"?>
<numbers><three>3</three><one>1</one><two>2</two><four>4</four></numbers>
精彩评论