Chapter 4: Using the XML Class


In the earlier chapters, you learned about XML and some of the related technologies. We covered the uses for XML and the advantages that it provides over other forms of data storage. In this chapter, well look at how to work with XML in Flash. Youll create Flash movies that include data from external XML documents. Youll also create and modify XML content within Flash and learn how to send it to other applications. Well work through several examples so that you can practice what we cover.

This chapter will introduce you to the XML classthe most common way to work with XML documents in Flash. In Chapters 8 and 9, well look at another way to work with XML documents: by using data components .

If youre not familiar with object-oriented programming, the term class refers to the design of an object. It specifies the rules for the way the object works and lists all the methods and properties for the object. The XML class contains all the information needed for working with XML objects in Flash.

The XML class was introduced in Flash 5, and since that time, the ActionScript associated with it hasnt changed significantly. The XML class became a native object in Flash 6, which increased its speed compared with Flash 5. The XML class stores XML content in document trees within Flash. The class allows you to

  • Create new XML documents or fragments

  • Load external XML documents

  • Modify XML content

  • Send XML information from Flash

The XML class includes methods and properties to work with XML document trees. Youll also use a related class, the XMLNode class, which allows you to work with specific nodes in an XML document tree. You can find a summary of the methods, properties, and events of both classes in the tables at the end of this chapter.

When we create a new XML object from the XML class, we call the object an instance of the class, and the process of creating the object is known as instantiation . One way to view the difference is to see the XML class as a template that you use to create XML objects.

Well start this chapter by learning how to load an external XML document into a Flash XML object. Well look at how you can extract information from the document tree so you can add it to your Flash movie. You could do this with either a physical document saved with an .xml file extension or a stream of XML information. If youre working with an information stream, you can load XML content generated by a PHP, ColdFusion, or ASP.NET server-side page or from a web service. Well cover web services in Chapter 9.

Foundation XML for Flash
Foundation XML for Flash
ISBN: 1590595432
EAN: 2147483647
Year: 2003
Pages: 93
Authors: Sas Jacobs

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: