• 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: (no subject)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (no subject)


  • Subject: Re: (no subject)
  • From: "Nigel Garvey" <email@hidden>
  • Date: Fri, 7 Apr 2006 13:30:47 +0100

email@hidden wrote on Fri, 7 Apr 2006 07:59:07 +0100:

>------------------------------------------------
>set xmlFile to (choose file) as Unicode text
>
>tell application "System Events"
>    set titleValue to value of XML element "title" of XML element
>"channel" of XML element "rss" of contents of XML file xmlFile
>    display dialog "the title is " & titleValue
>end tell
>------------------------------------------------
>
>but the code I want where a POSIX path is used to identify the file
>to process, rather than having the user select it through a dialog,
>shown below, does not work, even when the same file is processed in
>both cases:
>------------------------------------------------
>set xmlFile to read file ("/valid/path/to/file/RSS.xml" as POSIX file)
>
>tell application "System Events"
>    set titleValue to value of XML element "title" of XML element
>"channel" of XML element "rss" of contents of XML file xmlFile
>    display dialog "the title is " & titleValue
>end tell
>------------------------------------------------

Hi, Will.

In the first script, you're setting 'xmlFile' to the alias returned by
'choose file'. In the second, you're setting it to the _contents_ of the
file referenced by the POSIX path. Unless the contents are themselves a
valid path to an XML file, you'll get an error later when you try to
access 'XML file xmlFile'. It looks as though you need to omit the words
'read file' from the first line.

NG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Converting Date-Time
  • Next by Date: Re: Do shell and ssh
  • Previous by thread: (no subject)
  • Next by thread: Store script as run only
  • Index(es):
    • Date
    • Thread