Re: XML Error - any insight
Re: XML Error - any insight
- Subject: Re: XML Error - any insight
- From: Emmanuel LEVY <email@hidden>
- Date: Wed, 18 Aug 2010 00:43:45 +0200
On Aug 17, 2010, at 8:18 PM, Steve Thompson wrote:
[...] set theAsset to (XMLXPath theXMLRoot with "asset[@id=\"" &
assetIDNumber & "\"]")
this is dangerous
set theData to "<asset id=\"" & assetIDNumber & "\">
this is dangerous
set XMLElementText to "<value id=\"" & item k of mdFields & "\">"
& item k of assetFieldValues & "</value>"
this is very dangerous
If there is a quote in any of the strings implied, this will fail. You
can cheat and escape one kind of quote and use the other to
encapsulate the string, but you cannot cheat if you may have both
kinds of quotes (and even so it's insane programming).
You must do:
xmlxpath thexmlroot with "asset[@id=$theid]" xpath variables
{theid:assetIDNumber}
(slightly rearranging your program)
set thenewnode to xmlnewsibling "<asset/>" etc.
xmlsetattribute thenewnode name "id" to "assetIDNumber"
and, for xmlelementtext, make a new node from scratch with xmlopen
"<value/>", then use xmlsetattribute and xmlsettext to set the id and
the text, and finally display it with xmldisplayxml.
Emmanuel
_______________________________________________
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/archives/applescript-users
This email sent to email@hidden