Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 18. XML and E4X > Converting XML and XMLList to a String

18.12. Converting XML and XMLList to a String

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.

18.12.1. Converting XMLList to a String

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:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial