in reply to parsing various xml responses

It works fine for me like this:

$ cat t.pl #!/usr/bin/perl # vim: set ts=8 sw=2 et: use strict; use warnings; use XML::Bare; use Data::Dump qw/dump/; my $page = <<XML; <?xml version="1.0" encoding="ISO-8859-1" ?> <PayoneerResponse> <Echo> <Status>000</Status> <Description>Echo Ok - All systems are up.</Description> </Echo> </PayoneerResponse> XML my $ob = new XML::Bare( text => $page ); my $root = $ob->parse(); print "here comes the description:\n"; print $root->{PayoneerResponse}{Echo}{Description}{value}; print "\n\nand here's a dump of \$root:\n"; print dump $root; $ ./t.pl here comes the description: Echo Ok - All systems are up. and here's a dump of $root: { PayoneerResponse => { Echo => { Description => { _i => 95, _pos => 4, _z => 149, value = +> "Echo Ok - All systems are up." }, Status => { _i => 73, _pos => 3, _z => 91, value => "000 +" }, _i => 66, _pos => 2, _z => 158, value => "\n", }, _i => 47, _pos => 1, _z => 178, value => "\n", }, _i => -273705520, _pos => 0, _z => 0, value => " \n", }

Are you using the {value} key?

Replies are listed 'Best First'.
Re^2: parsing various xml responses
by Anonymous Monk on Dec 14, 2009 at 02:37 UTC
    Yes, when I exit out with output to test it I print to html this:
    print qq~ \$root->{xml}->{PayoneerResponse}->{Echo}->{Status}->{value}='~, $root +->{xml}->{PayoneerResponse}->{Echo}->{Status}->{value}, qq~'; \$root->{PayoneerResponse}->{Echo}->{Status}->{value}='~, $root->{Payo +neerResponse}->{Echo}->{Status}->{value}, qq~'; \$root->{Status}->{value}='~, $root->{Status}->{value}, qq~'; ~;
    Which prints this to the HTML output:
    $root->{xml}->{PayoneerResponse}->{Echo}->{Status}->{value}='';
    $root->{PayoneerResponse}->{Echo}->{Status}->{value}='';
    $root->{Status}->{value}='';

    So I have tried a lot of different ways and cannot get it to work.

    Can you see what I'm doing wrong in the $root variables or anything?

    Thanks
    Richard
      I even tried taking out the other -> in the code:
      print qq~ \$root->{PayoneerResponse}{Echo}{Status}{value}='~, $root->{PayoneerRe +sponse}{Echo}{Status}{value} ,qq~'; \$root->{Status}{value}='~, $root->{Status}{value}, qq~'; ~;
      which prints this result:
      $root->{PayoneerResponse}{Echo}{Status}{value}='';
      $root->{Status}{value}='';

      Still does not work.

      Richard
      I got it to work... I had an error up top.

      Thank you much!

      Richard