The freely intermixing of psuedo-XML and MillScript was came from the idea of Embedded SQL. I say "psuedo-XML" because there are a number of fairly difficult compromises to be made and the best resolution (in my opinion) is achieved by limiting the faithfulness of the XML simulation.
In MillScript the compromise is as follows. You can embed matching start and end tags in the program text. Between the tags there is ordinary MillScript. The attribute values of the start tags are written as MillScript basic-expressions, i.e. general expressions must be parenthesized. The shorthand for empty elements, in which the start tag is terminated by "/>" and so acts as its own end tag, is also allowed.
The effect of the start and end tags is to construct a lightweight XML-object; MillScript XML-objects are roughly half the size of their DOM equivalents. The fact that the objects are constructed rather than simply printed to a file is an absolutely vital factor in the effectiveness of MillScript. It is only because of this that it is possible to write stylesheet-like functions in MillScript.
Another difference between MillScript XML-objects and DOM-objects is that the children of MillScript's objects may be any legal values whatsoever. The most practical value are, of course, simple strings and numbers. However, there is no reason why boolean values, for example, could not be used as well. The final difference is that MillScript's XML-objects are not as extensible and updateable as DOM-objects.
The result of these decisions is that the embedding is recursive. It is possible, indeed perfectly typical, to nest an expression many levels deep with MillScript and psuedo-XML freely intermixed. This is a unique property of MillScript. Here's a typical, simple example.
function makeRoundedTable( x ) =>
# return a 3x3 table with "x" embedded in the center
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="top-left.gif"/></td>
<td>"\ "</td>
<td><img src="top-right.gif"/></td>
</tr>
<tr>
<td>"\ "</td>
<td> x </td> # embed reference to x
<td>"\ "</td>
</tr>
<tr>
<td><img src="bottom-left.gif"/></td>
<td>"\ "</td>
<td><img src="bottom-right.gif"/></td>
</tr>
</table>
endfunction;
# Now use this function
makeRoundedTable( <p> "This is how we use MillScript" </p> );
To access MillScript's XML objects there is a small handful of functions :-
isElement( element ) -> boolean
children( element ) -> list of objects
attribute( element, string ) -> object
attributesMap( element ) -> map from string to object