[ic] Still trying to parse XML
Ed LaFrance
edl at newmediaems.com
Thu Oct 2 16:31:33 EDT 2003
At 02:53 PM 10/2/2003 -0700, you wrote:
>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:
Other possible problems aside, you cannot use the print function in an
interchange usertag; STDIN and STDOUT are closed. Try appending the stuff
you want to see to a string and returning that, just as a rough test as to
whether or not it is working, i.e.:
my $out = <<EOA;
Transaction : $transaction->{ItemId}
Buyer User ID: $transaction->{Buyer}->{User}->{UserId}
Buyer Email : $transaction->{Buyer}->{User}->{Email}
EOA
return $out;
- Ed L.
>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
>
>_______________________________________________
>interchange-users mailing list
>interchange-users at icdevgroup.org
>http://www.icdevgroup.org/mailman/listinfo/interchange-users
===============================================================
New Media E.M.S. Technology Solutions for Business
11630 Fair Oaks Blvd., #250 eCommerce | Consulting | Hosting
Fair Oaks, CA 95628 edl at newmediaems.com
(916) 961-0446 http://www.newmediaems.com
(866) 519-4680 Toll-Free (916) 961-0447 Fax
===============================================================
More information about the interchange-users
mailing list