• 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: syntax problem for reading an xml file in a bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: syntax problem for reading an xml file in a bundle


  • Subject: Re: syntax problem for reading an xml file in a bundle
  • From: Graham Anderson <email@hidden>
  • Date: Thu, 27 Jan 2005 18:10:11 -0800

here's the strange problem....
I can not seem to read a file in the contents folder of my applescript application's Contents


set gLocalPrefFile to (((path to me) as string) & "Contents:Resources:Data:Preferences.xml";)
set theScript to "sed -n '/<launcherVer>/{s/.*<launcherVer>\\(.*\\)<\\/launcherVer>.*/\\1/p;}' " & POSIX path of gLocalPrefFile
set localVer to do shell script theScript


does not return anything and gives an error:(
when compiled and put into a dmg volume, I am getting type 1 errors


if I set the location of the gLocalPrefFile file to (path to preferences as string) & "!Fonovisa.xml" ...outside the Contents folder
it work just fine....
set theScript to "sed -n '/<launcherVer>/{s/.*<launcherVer>\\(.*\\)<\\/launcherVer>.*/\\1/p;}' ~/Library/Preferences/Preferences.xml"
set localVer to do shell script theScript
this works like a charm :)


I guess writing the preferences.xml file to the preference folder would be preferable anyway ?

but then again, I'm on my 7th? day of applescript

g

On Jan 27, 2005, at 5:16 PM, Christopher Nebel wrote:

On Jan 27, 2005, at 12:27 PM, Graham Anderson wrote:

I am trying to read an xml file located in my script's application bundle
I am not running this within script editor as it would generate erros....
set gLocalPrefFile to (((path to me) as string) & "Contents:Resources:Data:!Fonovisa.xml";)
set theScript to "sed -n '/<launcherVer>/{s/.*<launcherVer>\\(.*\\)<\\/launcherVer>.*/\\1/p;}' " & POSIX path of gLocalPrefFile
the xml file contains:
<?xml version="1.0" ?>
<preferences>
<launcherVer>1.0.0.37</launcherVer>
</preferences>

Knowing what error you're seeing would help. You might be having quoting trouble with the file path, seeing as how you're not quoting it at all -- say "quoted form of POSIX path of ..." instead.



--Chris Nebel AppleScript Engineering

P.S.: Personally, I prefer saying

    perl -ne 'print $1 if m|<launcherVers>(.*)</launcherVers>|'

...as I find it somewhat clearer, but that's a matter of taste.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ 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
  • Follow-Ups:
    • Re: syntax problem for reading an xml file in a bundle
      • From: Christopher Nebel <email@hidden>
References: 
 >syntax problem for reading an xml file in a bundle (From: Graham Anderson <email@hidden>)
 >Re: syntax problem for reading an xml file in a bundle (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: Localize weekdays
  • Next by Date: Re: Localize weekdays
  • Previous by thread: Re: syntax problem for reading an xml file in a bundle
  • Next by thread: Re: syntax problem for reading an xml file in a bundle
  • Index(es):
    • Date
    • Thread