What are all the programming languages that support XML literals natively or via extension? I know of VB.NET, Scala, and Factor. Any others?
Asked
Active
Viewed 520 times
9
-
1It seems a little odd to count languages where somebody had to write an extension to the compiler in C++, but not count languages which were flexible enough that someone could write an extension to the language in itself. – Ken Oct 12 '10 at 16:12
-
@Ken: +1, good point. Added Factor to the list. Thanks. – missingfaktor Oct 12 '10 at 16:22
-
I don't know of a library that does it, but Common Lisp supports reader macros, which enables you to define your own syntax. – Ken Oct 13 '10 at 14:12
5 Answers
5
Racket provides support for XML literals via XML Boxes. It also provides a very convenient S-expression based syntax for literal XML called X-expressions.

Sam Tobin-Hochstadt
- 4,983
- 1
- 21
- 43
-
1
-
You can directly write XML, using XML syntax. Here's a screenshot: http://www.ccs.neu.edu/home/samth/tmp/xmlbox.png – Sam Tobin-Hochstadt Oct 13 '10 at 12:53
4
Facebook published a PHP Extension that allows XML document fragments to be embedded in PHP code.
From the documentation page linked to above:
XHP is a PHP extension which augments the syntax of the language such that XML document fragments become valid PHP expressions. This allows you to use PHP as a stricter templating engine and offers much more straightforward implementation of reusable components.

Dominic Barnes
- 28,083
- 8
- 65
- 90
2
Perl? I've never used it, but XML::Literal looks like a way to do XML literals in Perl.

Ken
- 1,159
- 1
- 9
- 13