Skip navigation

Setting HTML text with applescript

193 Views 2 Replies Latest reply: Feb 4, 2013 1:56 AM by bth24199 RSS
bth24199 Calculating status...
Currently Being Moderated
Feb 3, 2013 8:15 PM

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)
  • red_menace Level 6 Level 6 (14,275 points)
    Currently Being Moderated
    Feb 3, 2013 9:20 PM (in response to bth24199)

    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>"

Actions

More Like This

  • Retrieving data ...

Bookmarked By (1)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.