• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: using XML directly from the web rather than a file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using XML directly from the web rather than a file?


  • Subject: Re: using XML directly from the web rather than a file?
  • From: "Steven D. Majewski" <email@hidden>
  • Date: Mon, 12 Feb 2007 23:12:52 -0500


On Feb 12, 2007, at 8:05 PM, David A. Cox wrote:

I am looking to parse and use data stored in XML available from a web source. I can deal with the data if I first write the data to a local xml document, and then read it in using the System Events xml support. But dealing with all that disk IO for a quick lookup of data seems like not the best answer. I would rather be able to download and use the data directly inside the script, but it seems to treat the xml data as a string rather than an xml object, and I using things like the "as xml data" do not seem to work. If I am missing something simple here, I would love a pointer in the right direction. I think I have run myself in about as many circles as I can on web searches :).

A sample of what I am doing at this point is:


--clear out the file try do shell script "rm /tmp/galacticaText" end try

--fill the file with xml data
do shell script "curl 'http://galacticaa.net/widget/feed.php? ts=1171327909000&v=2.1' > /tmp/galacticaText"


--read in the data, and break it out into variables we can use later in the script
tell application "System Events"
set GalacticaXML to XML file "/tmp/galacticaText"
set {EpNum, EpName, EpType, EpIm, EpM, EpD, EpY, EpFul, EpSum, NewVer, UpgradeMessage} to value of XML elements of XML element "galacticaa" of GalacticaXML
end tell

Try something like:

do shell script "curl 'http://galacticaa.net/widget/feed.php? ts=1171327909000&v=2.1'"

tell application "System Events"

make new XML data with properties {text:result}
set {EpNum, EpName, EpType, EpIm, EpM, EpD, EpY, EpFul, EpSum, NewVer, UpgradeMessage} to value of XML elements of XML element "galacticaa" of result

end tell


{"315", "A Day in the Life", "New", "yes", "02", "18", "2007", "February 18", "On his wedding anniversary, Adama is haunted by the memory of his late wife and the fate of their marriage.", "no", "#"}


If you go to lists.apple.com and search applescript-users for "XML suite" ,
you'll find that and a bunch of other tips. If you should need to do something
like the above repeatedly in the same script, then see this thread in particular:


http://lists.apple.com/archives/applescript-users/2005/Oct/msg00380.html
http://lists.apple.com/archives/applescript-users/2005/Oct/msg00409.html

-- Steve Majewski

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: using XML directly from the web rather than a file?
      • From: kai <email@hidden>
References: 
 >using XML directly from the web rather than a file? (From: "David A. Cox" <email@hidden>)

  • Prev by Date: using XML directly from the web rather than a file?
  • Next by Date: Re: using XML directly from the web rather than a file?
  • Previous by thread: using XML directly from the web rather than a file?
  • Next by thread: Re: using XML directly from the web rather than a file?
  • Index(es):
    • Date
    • Thread