• 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: XML Error - any insight
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >XML Error - any insight (From: Steve Thompson <email@hidden>)

  • Prev by Date: Re: How to speed up execution time of this script
  • Next by Date: A Replace() function
  • Previous by thread: Re: XML Error - any insight
  • Next by thread: A Replace() function
  • Index(es):
    • Date
    • Thread