Adding an element to XML
Adding an element to XML
- Subject: Adding an element to XML
- From: Darwin Zins <email@hidden>
- Date: Wed, 12 Mar 2003 01:07:46 -0600
I have the following construct:
set z_contacts to (((path to current user folder) as text) &
folderZOSXSync & ":addressbook.xml")
open for access file z_contacts returning inputFile
set theXMLSource to read inputFile
close access inputFile
set theXML to parse XML theXMLSource
tell application "Address Book"
save addressbook
repeat with aCard in every person
repeat with anItem in XML contents of theXML
if XML tag of anItem is equal to "Contacts" then
-- some code snipped
-- didn't find in the Zaurus Address Book, so add it
if found_in_z is false then
set myUid to my get_z_uid()
display dialog myUid
set XML contents of anItem to XML contents of anItem & ,
{class:XML element, XML tag:"Contact", XML
attributes:{|Uid|:myUid as string, |FirstName|:first name of aCard as
string, |MiddleName|:middle name of aCard as string, |LastName|:last
name of aCard as string, |Suffix|:suffix of aCard as string,
|JobTitle|:job title of aCard as string, |Company|:organization of
aCard as string, |Notes|:note of aCard as string}}
end if -- if found_in_z is false
end if
end repeat -- repeat with anItem in XML contents of theXML
end repeat -- repeat with aCard
end tell -- Address Book
-- Write out the Zaurus Address Book XML File
set theXMLSource to generate XML theXML
When it gets to the generate XML if it has to add an element, it stops
and all it says is "Can't continue". Am I missing something obvious
that anyone can see in adding the XML element?
Thanks for any help,
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.