• 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: Getting started with XML?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting started with XML?


  • Subject: Re: Getting started with XML?
  • From: Luther Fuller <email@hidden>
  • Date: Wed, 7 Feb 2007 18:24:27 -0600

The only reliably safe method of reading a .plist file is to read the whole file into a record, like this ...

	-- plistAlias is an alias to a plist file
	tell application "System Events"
		plistAlias as text
		set plistRec to (value of property list file the result)
	end tell

(Dictionaries in the plist file become sub-records within plistRec, arrays become lists, other kinds are obvious.)

If there are missing items in the plistRec, do this ...

property defaultRec : {Total Time:__, Year:__, Library Folder Count:__, Bit Rate"__, ....}

(You have to fill-in the blanks with default values that make sense. Usually these will be 0, "" or {}.) Then ...

	set plistRec to (plistRec & defaultRec)

plistRec now contains all the values that were in the original plist file, together with the missing values from the defaultRec. Only the missing values are replaced by defaults. That's the way concatenation works with records.

What, you may ask is the structure of plistRec? The only way to know this is to install "Property List Editor.app" from Developer Tools, then use it to open and inspect the plist file. (Don't even think of "Dump"ing the file! It only adds confusion.)
_______________________________________________
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: Getting started with XML?
      • From: kai <email@hidden>
References: 
 >Re: Getting started with XML? (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: applescript saveas menu action
  • Next by Date: Re: Getting started with XML?
  • Previous by thread: Re: Getting started with XML?
  • Next by thread: Re: Getting started with XML?
  • Index(es):
    • Date
    • Thread