Loading XML data using ActionScript 3.0
Loading XML data using ActionScript 3.0
By Blue_Chi | Flash CS3 | ActionScript 3.0 | Beginner
Using XML is one of the best ways for structuring external content in a logical format that is easy to understand, process, and update. This tutorial will teach you the basics on how to load and process XML in Flash using ActionScript 3.0. You are assumed to have basic knowledge of ActionScript in order to follow this tutorial.
This tutorial is for working with XML in ActionScript 3.0. If you would like to learn how to work with XML in ActionScript 1/2 then please review our previous Flash XML tutorial.
Our tutorial will be divided into the following short sections:
What is XML?
Writing an XML File for Flash.
Loading XML in Flash.
Processing XML in Flash.
What is XML?
XML stands for Extensible Markup Language, it is a markup language used to structure data logically using tags that look very similar to HTML. However, when using HTML you use existing tags to create your web pages, but in XML you create you own tags which you later use in your program the way you choose. This makes it easy to create tags which are descriptive of your project and understandable by any human being. For example, you do not need any preliminary knowledge about XML or the program that uses it to figure out the purpose of the sample code below:
<?xml version="1.0" encoding="utf-8"?>
<GALLERY>
<IMAGE TITLE="school">image1.jpg</IMAGE>
<IMAGE TITLE="garden">image2.jpg</IMAGE>
<IMAGE TITLE="shop">image3.jpg</IMAGE>
</GALLERY>
As you just saw, XML makes it possible for authors to create and name their tags in whatever form they choose as long as they adhere to the basic rules of the language. Another main feature of any XML document is that the tags of an XML document define elements which are structured in a parent/child manner, where each tag may have a number of children tags but only one parent.
Moving on the actual content
Ïà¹ØÎĵµ£º
XML DOM½éÉÜ
Ò»¡¢XML DOM¼ò½é
DOM£¨Document Object Model£¬Îĵµ¶ÔÏóÄ£ÐÍ£©ÊÇÒ»ÖÖÓ¦ÓóÌÐò½Ó¿Ú£¨API£©µÄÓ¦Óã¬Ëü½«Îĵµ£¨ÈçXMLÎĵµ£¬HTMLÎĵµµÈ£©¿´³ÉÊÇÒ»¸öÎĵµ¶ÔÏó£¬È»ºóͨ¹ý³ÌÐòÓïÑÔ£¨ÈçJavaScriptµÈ½Å±¾ÓïÑÔ£¬C++µÈ£©µ÷ÓøÃÎĵµ¶ÔÏ󣬶ÔÎĵµÖеÄÊý¾Ý½øÐдæÈ¡£¬²¢ÀûÓóÌÐò¶Ô»ñÈ¡µÄÊý¾Ý½øÐиú½øÒ»²½µÄ´¦Àí¡£
X ......
³£ÓõÄϵÁл¯¶¨Ò壨using System.Xml.Serialization;£©
[XmlAttribute("name")] // ¶¨Òå<Tag name="…"></Tag>
[XmlElement("label")] // ¶¨Òå<label>…</label>
[XmlIgnoreAttrib ......
ÔÚMFC³ÌÐòÖÐʹÓÃXMLÎļþÅäÖù¤¾ßÀ¸
×÷ÕߣºÖì½ð²Ó
À´Ô´£ºhttp://www.cnblogs.com/clever101
ÏÖÔÚÎÒ·¢ÏÖʹÓÃVisual StudioµÄ×ÊÔ´±à¼Æ÷½øÐбà¼×ÊÔ´ÓÐ×ÅÖî¶àµÄ²»±ã£ºÊ×ÏÈÊÇÈκÎ×ÊÔ´µÄ±ä¶¯Ò»°ã±ä¶¯´úÂ룬²»ÀûÓÚϵͳά»¤£¬Æä´ÎVisual StudioµÄ×ÊÔ´±à¼Æ÷µÄ±¾ÉíµÄ¹¦ÄÜÓÐÏÞ£¬Ò²²»ÀûÓÚ½çÃæÃÀ»¯£¬ÈýÊDz»ÀûÓÚÈËÔ±·Ö¹¤£¬¿ª·¢ÈËÔ±¼ ......
Îå¡¢XMLģʽ
l XMLģʽÄܸü¾«È·µÄ´¦ÀíXML½á¹¹Ô¼ÊøµÄ±íʾ֮Íâ»¹ÎªÔ¼ÊøÊý¾ÝµÄ´¦ÀíÌṩһ¸öXMLÑùʽ¡£Ä£Ê½Ö»ÊÇÒ»¸öXMLÎĵµ£¬ÊÜDTDµÄÔ¼Êø¡£¶ÔÓÚXMLģʽ¶øÑÔ£¬XML DTDÖ»ÊÇÒ»ÖÖ´´½¨ÎĵµÔ¼ÊøµÄÊֶΡ£ÒòΪXMLģʽÊÇΪÁËÇ¿»¯XMLÎĵµµÄÓÐЧÐÔ£¬Ëü±ØÐë²ÉÓÃÒ»ÖÖ»úÖÆ£¬¶ø²»ÊÇ×Ô¼º¶¨ÒåÔ¼ÊøÌõ¼þ¡£ÕâÖÖ»úÖÆ±ØÐëÊÇÒ»¸öDTD¡£µ«ÊÇÔʼµÄD ......