XML processing tips

Hi guys and gals

I was looking for some tips. I have some XML data I wanted to get into filemaker pro. Right now I am using perl to retrieve the data and I wanted to get this into a FMP data base. I was thinking that applescript would be my best bet to process this. I was looking for some direction to focus my efforts.

My perl skills are very weak.
Applescript skill are much better.
The data is ebay category information so it could large. (sample below)
FMP 5.5 (could upgrade to 6 or 7 if needed)
Mac os 10.4.2

<?xml version="1.0" encoding="UTF-8"?>

2006-09-13T08:29:19.444ZSuccess477e477_core_Bundled_3514903_R1truetrue200811Antiques20081falsefalsefalsefalsefalsefalse

Thanks
Joe

There are AppleScript tools for parsing XML, like Satimage’s, but I couldn’t manage to parse your example using them, so I suspect it is ill formed, incomplete, or unique to ebay. You’ll have to pursue the document object model ebay uses.

Hi Adam

Thanks for your effort. That was just a sample from the begining.

I pasted this from the terminal window. So I actually need to get this from the terminal to applescript.

This is all of what was returned.

Now that I am looking at it it seems that it seems to be cutting some off at the end.

Thanks Joe

Last login: Wed Sep 13 08:54:11 on console
Welcome to Darwin!
PowerBook:~ joeberes$ /Library/Perl/getcatsL1.1.pl

<?xml version="1.0" encoding="UTF-8"?>

2006-09-13T08:29:19.444ZSuccess477e477_core_Bundled_3514903_R1truetrue200811Antiques20081falsefalsefalsefalsefalsefalsetruetrue5501Art550falsefalsefalsefalsefalsefalsetruetrue29841Baby2984falsefalsefalsefalsefalsefalsetruetrue2671Books267falsefalsefalsefalsefalsefalsetruetrue125761Business & Industrial12576falsefalsefalsefalsefalsefalsetruetrue6251Cameras & Photo625falsefalsefalsefalsefalsefalsetruetrue150321Cell Phones15032falsefalsefalsefalsefalsefalsetruetrue114501Clothing, Shoes & Accessories11450falsefalsefalsefalsefalsefalsetruetrue111161Coins & Paper Money11116falsefalsefalsefalsefalsefalsetruetrue11Collectibles1falsefalsefalsefalsefalsefalsetruetrue580581Computers & Networking58058falsefalsefalsefalsefalsefalsetruetrue2931Consumer Electronics293falsefalsefalsefalsefalsefalsetruetrue143391Crafts14339falsefalsefalsefalsefalsefalsetruetrue2371Dolls & Bears237falsefalsefalsefalsefalsefalsetruetrue112321DVDs & Movies11232falsefalsefalsefalsefalsefalsetruetrue451001Entertainment Memorabilia45100falsefalsefalsefalsefalsefalsetruetrue314111Gift Certificates31411falsefalsetruefalsefalsefalsetruetrue263951Health & Beauty26395falsefalsefalsefalsefalsefalsetruetrue117001Home & Garden11700falsefalsefalsefalsefalsefalsetruetrue2811Jewelry & Watches281falsefalsefalsefalsefalsefalsetruetrue112331Music11233falsefalsefalsefalsefalsefalsetruetrue6191Musical Instruments619falsefalsefalsefalsefalsefalsetruetrue8701Pottery & Glass870falsefalsefalsefalsefalsefalsetrue105421Real Estate10542falsefalsefalsefalsefalsetruetrue3161Specialty Services316falsefalsefalsefalsefalsetruetruetrue3821Sporting Goods382falsefalsefalsefalsefalsefalsetruetrue644821Sports Mem, Cards & Fan Shop64482falsefalsefalsefalsefalsefalsetruetrue2601Stamps260falsefalsefalsefalsefalsefalsetruetrue13051Tickets1305falsefalsefalsefalsefalsetruetruetrue2201Toys & Hobbies220falsefalsefalsefalsefalsefalsetruetrue32521Travel3252falsefalsefalsefalsefalsetruetruetrue12491Video Games1249falsefalsefalsefalsefalsefalsetruetrue991Everything Else99falsefalsefalsefalsefalsefalsetrue20381Live Auctions2038falsefalsefalsefalsefalsetruetrue101591Partner10159falsefalsefalsefalsefalsefalse352006-08-15T02:21:42.000Z65falsetrue0.0truefalse</ReduceReserv

PowerPowerBook:~ joeberes$

Now that I have posted it seem even what I posted seems to have changed from what I pasted. I guess I must be doing something wrong.

Thanks
Joe

Heres a link to the file.

http://homepage.mac.com/jman1/sale/ebayXMLfile.rtf
http://homepage.mac.com/jman1/sale/ebayXMLfile.rtf

Unless you must, saving that as rtf just complicates things because the parser doesn’t know how to deal with the rtf formatting. It should be plain unicode text.

The link you gave is to a file on your machine rather than on ebay’s, but here’s how you get a link’s contents into an AppleScript:


set xml to do shell script "curl [url=http://homepage.mac.com/jman1/sale/ebayXMLfile.rtf]http://homepage.mac.com/jman1/sale/ebayXMLfile.rtf"[/url]

Thanks Adam

I took your script and changed it to

set xml to do shell script “Perl /Library/Perl/getcatsL1.1.pl”

This is the perl script I run from the Terminal to get the xml info from ebay.

I get this error message in response.

Can’t locate LWP/UserAgent.pm in @INC (@INC contains: /System/Library/Perl/5.8.6/darwin-thread-multi-2level /System/Library/Perl/5.8.6 /Library/Perl/5.8.6/darwin-thread-multi-2level /Library/Perl/5.8.6 /Library/Perl /Network/Library/Perl/5.8.6/darwin-thread-multi-2level /Network/Library/Perl/5.8.6 /Network/Library/Perl /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.6 /Library/Perl/5.8.1 .) at /Library/Perl/getcatsL1.1.pl line 3.
BEGIN failed–compilation aborted at /Library/Perl/getcatsL1.1.pl line 3.

Do I have to tell applescript where LWP user agent is ??

The script does run when I do it from terminal.

Thanks
Joe