开发者

XML::Hash::LX - Convert hash to xml: not the expected output

开发者 https://www.devze.com 2023-02-02 04:19 出处:网络
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?

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消