To simplify things a bit, I would suggest the use of angle brackets instead of parentheses:<p><pre><code> <tagname <@ attr "value" attr2 "value2">
<tagname2>
<tagname3 "data">>
</code></pre>
Going a bit further, we could require the `@`, and place it <i>after</i> the attributes list. This format has fewer special cases:<p><pre><code> <tagname attr "value" attr2 "value2" @
<tagname2 @>
<tagname3 @"data">>
</code></pre>
Finally, we could remove the quotes around the raw strings ("data"), while inverting the brackets:<p><pre><code> >tagname attr "value" attr2 "value2" @
>tagname2 @<
>tagname3 @data<<
</code></pre>
This may look twisted, but we stay very close to true S-expressions, while using the same escape characters we have in plain XML.
Nice!<p>And a good time to remember Erik Naggum's epic S-exps vs. XML rant:<p><a href="http://harmful.cat-v.org/software/xml/s-exp_vs_XML" rel="nofollow">http://harmful.cat-v.org/software/xml/s-exp_vs_XML</a>
Can you easily filter raw text out of a Sexp stream? I don't think so. It would require a full Sexp machine to read and "understand" the tree, whereas with markup-style data streams it takes a trivial regexp to extract text. (Why would you need this? Search/indexing, for example.)