Click here to browse the Flash Tutorial column
Regarding the application of XML in FLASH, I have written several articles before. I also collected several articles from the Internet. However, they are all very simple and commonly used ones. Here, I summarize other related explanations of XML. If there are any shortcomings, I hope everyone can complement each other. Just for a common purpose: to improve together.
1. Requirements for writing standard XML
Click here to browse the Flash Tutorial column
Regarding the application of XML in FLASH, I have written several articles before. I also collected several articles from the Internet. However, they are all very simple and commonly used ones. Here, I summarize other related explanations of XML. If there are any shortcomings, I hope everyone can complement each other. Just for a common purpose: to improve together.
1. When writing standard XML, you need to pay attention to the following points:
list
- paddingleft-2">
A standard XML document must start with "" on the first line and end with "/>" , the beginning of which needs to declare the XML version, such as: version="1.0", and should also include a statement about encoding: "encoding="utf-8""; XML requires that all tags must be closed before the end of the document. If the tag contains content, it must be written in the format of "
content name>". If the content is empty, it should be written in The format of name>; that is, it must be followed by . Every XML has a root element, also called the root node. Nodes have node values and attributes. If the XML node value contains the same characters as XML tag keywords, XML will not be able to parse the document. For example, if a node value is a greater than or less than sign, the interpreter will generate an error.
2. Create a simple instance in FLASH:
//创建一个新的XML类实例 var my_XML:XML=new XML(); //创建一个TextArea组件,用于显示此XML内容 var my_TextArea:mx.controls.TextArea; //加载外部XML文件 my_XML.load("my_xml.xml"); //为load函数定义onLoad函数---此处是必须的。只有当加载成功后,才能控制XML。否则不能。 my_XML.onLoad=function(ok:Boolean){ if(ok){ my_TextArea.text =this; }else{ my_TextArea.text ="加载失败..." } } //忽略空白: my_XML.ignoreWhite=true;
3. Detailed explanation on FLASH parsing XML, To put it bluntly, it is the reading of nodes.
First of all, let’s take a look at this picture and add a little impression.
Below, I will give a detailed introduction to the parsing of XML files.
For the convenience of explanation, here I give a simple example.
1、新建一个记事本文件,在里面输入如下内容: <购买物品> <衬衣 颜色="白色" 品牌="雅戈尔">1件</衬衣> <裤子 颜色="深蓝" 品牌="王子裤">2件</裤子> <鞋子 颜色="黑色" 品牌="红蜻蜓">3双</鞋子> <总花费金额> <打的费>50元</打的费> <货物金>1000元</货物金> </总花费金额> </购买物品> 然后保存为"goods.xml",注意,在编码处,要选择"Unicode"。 2、下面,就对里面的各项值进行解读。 读取整个XML文件的方法: 在刚才的XML的同级目录下新建一FLA文件,然后在场景中放置一TextArea组件。并赋实例名“my_TextArea”, 然后在第一帧中添加如下代码: var my_XML:XML=new XML(); System.useCodepage=true; var my_TextArea:mx.controls.TextArea; my_XML.load("goods.xml") my_XML.onLoad=function(ok:Boolean){ if(ok){ my_TextArea.text =this; }else{ my_TextArea.text ="加载失败" } } 按CTRL ENTER测试,即可以看效果。 首先,我们来看看如何对XML中的节点名称或者节点属性进行读取呢? 比如,我们要读取如例子中的"购买物品"这几个字符,该如何操作呢? 我们使用如下语句: this.firstChild.nodeName; 如果要读取"衬衣": this.firstChild.childNodes[0].nodeName; 如果要读取"1条": this.firstChild.childNodes[1].childNodes[0].nodeValue; 如果要读取裤子的品牌: this.firstChild.childNodes[1].attributes.品牌; 将XML读取进LIST组件中: System.useCodepage = true; var my_TextArea:mx.controls.TextArea; var my_List:mx.controls.List; var my_XML:XML = new XML(); my_XML.ignoreWhite = true; my_XML.load("shopping.xml"); my_XML.onLoad = function(ok:Boolean) { if (ok) { var childnodes = this.firstChild.childNodes; for (i=0; i<childnodes.length; i ) { my_List.addItem({label:childnodes.nodeName}); } } else { my_TextArea.text = "加载失败"; } }; 第一个节点:firstChild: 用法:this.firstChild; 最后一个节点:lastChild 用法:this.firstChild; 兄弟节点:nextSibling: 用法:this.firstChild.childNodes[0].nextSibling; 另一个兄弟节点:previousSibling: 用法:this.firstChild.childNodes[0].previousSibling; 区别:nextSibling是朝后,而previousSibling是当前之前; 父类节点:parentNode: 用法:this.firstChild.parentNode;
The above is the detailed content of Detailed introduction to the application of XML in FLASH. For more information, please follow other related articles on the PHP Chinese website!

The implementation of RSS in XML is to organize content through a structured XML format. 1) RSS uses XML as the data exchange format, including elements such as channel information and project list. 2) When generating RSS files, content must be organized according to specifications and published to the server for subscription. 3) RSS files can be subscribed through a reader or plug-in to automatically update the content.

Advanced features of RSS include content namespaces, extension modules, and conditional subscriptions. 1) Content namespace extends RSS functionality, 2) Extended modules such as DublinCore or iTunes to add metadata, 3) Conditional subscription filters entries based on specific conditions. These functions are implemented by adding XML elements and attributes to improve information acquisition efficiency.

RSSfeedsuseXMLtostructurecontentupdates.1)XMLprovidesahierarchicalstructurefordata.2)Theelementdefinesthefeed'sidentityandcontainselements.3)elementsrepresentindividualcontentpieces.4)RSSisextensible,allowingcustomelements.5)Bestpracticesincludeusing

RSS and XML are tools for web content management. RSS is used to publish and subscribe to content, and XML is used to store and transfer data. They work with content publishing, subscriptions, and update push. Examples of usage include RSS publishing blog posts and XML storing book information.

RSS documents are XML-based structured files used to publish and subscribe to frequently updated content. Its main functions include: 1) automated content updates, 2) content aggregation, and 3) improving browsing efficiency. Through RSSfeed, users can subscribe and get the latest information from different sources in a timely manner.

The XML structure of RSS includes: 1. XML declaration and RSS version, 2. Channel (Channel), 3. Item. These parts form the basis of RSS files, allowing users to obtain and process content information by parsing XML data.

RSSfeedsuseXMLtosyndicatecontent;parsingtheminvolvesloadingXML,navigatingitsstructure,andextractingdata.Applicationsincludebuildingnewsaggregatorsandtrackingpodcastepisodes.

RSS documents work by publishing content updates through XML files, and users subscribe and receive notifications through RSS readers. 1. Content publisher creates and updates RSS documents. 2. The RSS reader regularly accesses and parses XML files. 3. Users browse and read updated content. Example of usage: Subscribe to TechCrunch's RSS feed, just copy the link to the RSS reader.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.