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
相关文档:
常用的系列化定义(using System.Xml.Serialization;)
[XmlAttribute("name")] // 定义<Tag name="…"></Tag>
[XmlElement("label")] // 定义<label>…</label>
[XmlIgnoreAttrib ......
一、问题描述:
一个XML文档,名为OriginXml.xml,示例数据如下:
<?xml version="1.0" encoding="utf-8"?>
<Class>
<student id="2001001">
<name>张三</name>
<age>18</age>
<scores>
<语文>79</语文>
<数学&g ......
1 类似xmlns=""的文件
示例XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<WebSrvMessage xmlns="http://www.lenoval.com/">
<version>1.0</version>
<DataContent>
<DateTag>2010-5-17</DateTag>
</DataCont ......
前面文章中提到 xml节点的删除
“删除 <book genre="fantasy" ISBN="2-3631-4">节点的genre属性,删除 <book genre="update陶维佳" ISBN="2-3631-4">节点。”
代码:
XmlNodeList xnl=xmlDoc.SelectSingleNode("bookstore").ChildNodes;
foreach(XmlNode&nbs ......
通过调用CreateDataSetfromXml取得XML数据
Imports System.Xml
Public Const FILE_CONFIG = "MZZ.xml"
Public Const PATH_CONFIG = "\XML\"
Dim dstXML As DataSet
Dim tblXML_DB As DataTable
Dim dtCod As New DataTable
Dim strSQL As String = ""
clsPublic ......