Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Setting HTML text with applescript

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)

Posted on Feb 3, 2013 8:15 PM

Reply
Question marked as Best reply

Posted on Feb 3, 2013 9:20 PM

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:


settheTextto"<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 replies
Question marked as Best reply

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:


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

Setting HTML text with applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.