2 Replies Latest reply: Feb 4, 2013 1:56 AM by bth24199
bth24199 Level 1 Level 1 (0 points)

I am trying to set this text in apple script but I keep getting the error message "Expected expression ) but found <".  Here is the code:

 

          set theText to (<title>ArticleTitle</title> & return & <dc:creator>admin</dc:creator> & return & <content:encoded><![CDATA[ArticleSource & return & return & ArticleDescription & <a href="ArticleURL">More</a> & </content:encoded> & return <excerpt:encoded><![CDATA[]]></excerpt:encoded> & return <wp:post_date>ArticleDate</wp:post_date>)


OS X Mountain Lion (10.8.2)
  • 1. Re: Setting HTML text with applescript
    red_menace Level 6 Level 6 (14,615 points)

    AppleScript text strings are enclosed in quotes, and the concatenation character is the ampersand &.  In addition, quotes need to be escaped with the backslash character (you can also use the string constant quote, which doesn't need to be escaped), and of course a backslash character also needs to be escaped.

     

    If I understood your snippet, it would be something like:

     

    set theText to "<title>" & ArticleTitle & "</title>" & return & "<dc:creator>admin</dc:creator>" & return & "<content:encoded><![CDATA[" & ArticleSource & return & return & ArticleDescription & "<a href=\"" & ArticleURL & "\">More</a> & </content:encoded>" & return & "<excerpt:encoded><![CDATA[]]></excerpt:encoded>" & return & "<wp:post_date>" & ArticleDate & "</wp:post_date>"

  • 2. Re: Setting HTML text with applescript
    bth24199 Level 1 Level 1 (0 points)

    Thanks so much! I had already figured it out by the time you posted, but the logic you put behind it will definitely help me in the future.