Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
As we've seen throughout this chapter, E4X implements custom rules for converting XML and XMLList instances to a string. For reference and review, this section describes E4X's XML-to-string and XMLList-to-string conversion rules. Remember that an XML instance can represent five different kinds of content: an element, an attribute, a text node, a comment, or a processing instruction. We'll consider the conversion rules for each kind separately, but we'll start with XMLList-to-string conversion in preparation for the subsequent discussion.
When an XMLList has only one XML instance, the result of XMLList's toString( ) is exactly the same as the result of calling toString( ) on that one instance. For example, in the following code, the title variable refers to an XMLList whose single XML instance represents the <TITLE> element. Converting title to a string yields Ulysses, exactly as if toString( ) had been invoked on the single XML instance directly: