Re: Parsing phone/emails in Address Book
Re: Parsing phone/emails in Address Book
- Subject: Re: Parsing phone/emails in Address Book
- From: Darwin Zins <email@hidden>
- Date: Sat, 8 Mar 2003 10:52:28 -0600
Thank you, I really appreciate the advice. I now have:
tell application "Address Book"
repeat with aPerson in every person
tell aPerson
set a_business_phone to ""
set a_business_fax to ""
set a_home_phone to ""
set a_home_fax to ""
set a_home_mobile to ""
repeat with aPhone in (every phone of aPerson)
tell aPhone
set phoneLabel to (get the label as Unicode text)
if phoneLabel is equal to "home" then
set a_home_phone to (get the value as Unicode text)
else if phoneLabel is equal to "mobile" then
set a_home_mobile to (get the value as Unicode text)
else if phoneLabel is equal to "home fax" then
set a_home_fax to (get the value as Unicode text)
else if phoneLabel is equal to "work" then
set a_business_phone to (get the value as Unicode text)
else if phoneLabel is equal to "work fax" then
set a_business_fax to (get the value as Unicode text)
end if
end tell
end repeat
set a_emails to ""
repeat with aEmail in (every email of aPerson)
set a_emails to a_emails & " " & (get the value of aEmail as
Unicode text)
end repeat
set addressLabel to ""
set a_home_street to ""
set a_home_city to ""
set a_home_state to ""
set a_home_zip to ""
set a_home_country to ""
set a_work_street to ""
set a_work_city to ""
set a_work_state to ""
set a_work_zip to ""
set a_work_country to ""
repeat with aAddress in (every address of aPerson)
tell aAddress
set addressLabel to (get the label as Unicode text)
if addressLabel is equal to "home" then
set a_home_street to (get the street as Unicode text)
set a_home_city to (get the city as Unicode text)
set a_home_state to (get the state as Unicode text)
set a_home_zip to (get the zip as Unicode text)
set a_home_country to (get the country as Unicode text)
end if
if addressLabel is equal to "work" then
set a_work_street to (get the street as Unicode text)
set a_work_city to (get the city as Unicode text)
set a_work_state to (get the state as Unicode text)
set a_work_zip to (get the zip as Unicode text)
set a_work_country to (get the country as Unicode text)
end if
end tell
end repeat
set a_id to (get the id as Unicode text)
set a_modification_date to (get the modification date)
set a_creation_date to (get the creation date)
set a_first_name to (get the first name as Unicode text)
set a_middle_name to (get the middle name as Unicode text)
set a_last_name to (get the last name as Unicode text)
set a_suffix to (get the suffix as Unicode text)
set a_job_title to (get the job title as Unicode text)
set a_organization to (get the organization as Unicode text)
set a_birth_date to (get the birth date as Unicode text)
set a_note to (get the note as Unicode text)
end tell
end repeat
end tell
At the bottom of the loop I need to store this information and then
read information from a file and store the information from the file in
the same structure and then compare what's in the file with what's in
the Address Book. From what I am reading I am thinking that I should
copy all of the information in to an applescript Record and then append
that record to the end of a list at the bottom of the loop. Does that
sound like a reasonable way to do this or is there a better way? I am
thinking an object with all of these properties and then adding that
object to a collection manager. I am thinking that I have the
equivalent structures in applescript, maybe not, maybe there is a
better way.
The file is an xml file and here is a sample line:
<Contact FirstName="Tom" Uid="-1025720073" Company="Foothold
Technology" LastName="Mitchell" FileAs="Mitchell, Tom"
BusinessPhone="(212) 780-1450" BusinessFax="(212) 228-1351"
Emails="email@hidden" />
Each contact is a Contact element with just properties.
Is there an easy way to parse xml with applescript?
Thank you,
Darwin
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.