[ic] Still trying to parse XML

Grant listbox at email.com
Thu Oct 2 15:53:33 EDT 2003


I've been in contact with the author of the XML::Simple module and he's been
trying to help me get something together for parsing the XML response
received from the eBay API.  He gave me a sample script to work with based
on the sample XML I gave him and I turned it into a UserTag like this:


Usertag xml_simple Order
Usertag xml_simple Routine <<EOR
use XML::Simple;

sub {

my $xml = get_xml_string();

my $xs = XML::Simple->new(
  KeyAttr    => [ ],
  ForceArray => [ 'Transaction' ],
);

my $eBay = $xs->XMLin($xml);
my $result = $eBay->{GetSellerTransactionsResult};
my $transactions = $result->{Transactions}->{Transaction};

# Loop through each of the transactions
foreach my $transaction (@$transactions) {
  print "Transaction  : $transaction->{ItemId}\n";
  print "Buyer User ID: $transaction->{Buyer}->{User}->{UserId}\n";
  print "Buyer Email  : $transaction->{Buyer}->{User}->{Email}\n";

  last;  # Break out of the loop since the there only one in the test data
}

exit;

sub get_xml_string {
  # Simple test routine just returns a hard coded string
  return <<'EOF';
<?xml version="1.0" encoding="utf-8" ?>
<eBay>
        <GetSellerTransactionsResult>
                <Transactions>
                        <Transaction>
                                <Buyer>
                                        <User>
                                                <UserId>joe_punter</UserId>

<Email>joe at punter.com</Email>
                                        </User>
                                </Buyer>
                                <ItemId>578846</ItemId>
                        </Transaction>
                </Transactions>
        </GetSellerTransactionsResult>
</eBay>
EOF
}

}
EOR


However, calling this tag like [xml_simple] yields a 500 error with nothing
in the error.log files.  Does anyone see anything that might fix the tag?
He's too busy to work on it even if paid.

- Grant



More information about the interchange-users mailing list