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
  • PrintPrint
Share this Page URL
Help

Chapter 11. XML and E4X > Converting to and from Strings

11.4. Converting to and from Strings

XML objects are essentially text data. When interpreted as XML, they inherit the tree structure you're familiar with. Thankfully, it's easy to move back and forth between XML and strings. Besides the familiar toString() method, there are a few more options specifically for XML and XMLList objects.

11.4.1. Converting Strings to XML

You may find it necessary to convert string values to XML when working with data from a string-based source or an external text file. To do this, you can simply use the cast-like conversion function XML(). This looks just like casting the argument to XML. You should be careful to use only well-formed XML text when casting. Failure to do so will result in a runtime error.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint