`
wangangie19
  • 浏览: 43284 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

e4x - 对xml操作的一些示例

阅读更多

as3终于给了xml一个名分,使他成了真正的内置数据类型,
现在我们不必像以前一样,把xml转成数组或者object了,直接可以操作xml了
以下copy自as3 cookbook 第20章
[1b]写xml操作:[/1b]
var example:XML = ehbeesee;
[1b]用变量写:[/1b]
// Assume two variables exist, username and score
var username:String = "Darron";
var score:int = 1000;
// Use curly braces around the variable name to use its value when
// assigning XML via an XML literal
var example:XML =
 {username}
 {score}
 ;
[1b]字符串:[/1b]
// Create the XML structure with a string so use the value of both
// username and score inside of the XML packet.
var str:String = "" + username + ""
 + "" + score + "";
// Pass the string to the constructor to create an XML object
var example:XML = new XML( str );
[1b]填加元素[/1b]
// Create an XML instance to add elements to
var example:XML = ;
// Create a new XML node named newElement and add it to the
// example instance
example.newElement = ;
/* Displays:
 
 
 
*/
trace( example );
[1b]技巧:[/1b]
// Create an XML instance to work with
var example:XML = ;
var id:int = 10;
// Create a string to incorporate the value of id in the node name
example[ "user" + id ] = "";
/* Displays:
 
 
 
*/
trace( example );
[1b]“-” 会引起编译器错误,用数组操作符避免这个[/1b]
example.some-element = ""; // Generates a compiler error
example[ "some-element" ] = "";
[1b]insertChildBefore 和 insertChildAfter 作用[/1b]
// Create an XML instance to work with
var example:XML = ;
// Create an empty two element node
example.two = "";
// Before the two element node, add a one element node
example = example.insertChildBefore( example.two,  );
// After the two element node, add a three element node
example = example.insertChildAfter( example.two,  );
/* Displays:
 
 
 
*/
trace( example );
[1b]填加 文本节点 到xmlobject:[/1b]
// Create an XML instance to work with
var example:XML = ;
// Create a text node from a string
example.firstname = "Darron";
// Create a text node from a number
example.number = 24.9;
// Create a text node from a boolean
example.boolean = true;
// Create a text node from an array
example.abc = ["a", undefined, "b", "c", null, 7, false];
/* Displays:
 Darron
 24.9
 true
 a,,b,c,,7,false
*/
trace( example );
[1b]appendChild( ), prependChild( ), insertChildBefore( ), or insertChildAfter( ). 方法:[/1b]
// Create an XML instance to work with
var example:XML = ;
// Append a two element node containing a text node child
// with value 2
example.appendChild( 2 );
// Prepend a one element node containing a text node child
// with value "number 1"
example.prependChild( "number 1" );
// After the one element node, insert a text node with
// value 1.5
example.insertChildAfter( example.one[0], 1.5 );
// Before the two element node, insert a part element node
// containing a text node child with value 1.75
example.insertChildBefore( example.two[0], 1.75 );
/* Displays:
 "number 1"
本文转自:http://www.5uflash.com/flashjiaocheng/Flash-as3-jiaocheng/407.html
分享到:
评论

相关推荐

    x-SCAN -V3.3-CN.

    对远程操作系统识别功能进行了加强,并去掉了一些可由脚本完成的插件。 感谢isno和Enfis提供优秀插件,感谢悟休、quack帮忙精选nasl脚本列表,也感谢其他提供优秀思路和协助测试的朋友。 X-Scan v2.3 -- 发布日期...

    强大的扫描工具x-scan

    X-Scan v1.0(beta) -- 发布日期:07/12/2001,新增对远程操作系统类型及版本识别功能;新增对 远程主机地理位置查询功能;在“-iis”选项中,新增对IIS “.ida/.idq”漏洞的扫描,同时更新漏洞 描述;在“-port”...

    W2School_Web网站技术教程

    E4X WMLScript 服务器脚本 SQL ASP ADO PHP .NET(dotnet) .NET Microsoft .NET ASP .NET Mobile 多媒体 Media SMIL SVG 建站手册 网站构建 万维网联盟 (W3C) 浏览器信息 网站品质 语义网 职业规划 ...

    robotframework-jsonlibrary:Robotframework测试库使用JSONPath来操作JSON

    JSONPath从E4X借用此语法 * 通配符。 所有对象/元素,无论其名称如何。 [] 下标运算符。 XPath使用它来遍历元素集合和谓词。 在Javascript和JSON中,它是本机数组运算符。 [,] XPath中的Union运算符导致节点...

    JavaScript宝典(第7版)

    ● 使用Ajax、E4X/XML和JSON推动Web 2.0应用 ● 执行数据输入验证和提高安全性 配书光盘 配书光盘的精彩内容如下: ● 29个附赠章节,这些章节讨论了数据输入验证、脚本 调试和跨浏览器动态HTML等高级主题。 ● 可供...

    JavaScript宝典(第7版)( (美)Danny Goodman) 高清中文扫描版.pdf

    《javascript宝典(第7版)》内容简介:您想创建更具魅力的交互网页吗?您想更好地控制浏览器呈现内容的方式吗?经典畅销书们avascript宝典(第7版...使用ajax、e4x/xml利json推动web2.0应用 执行数据输入验证和提高安全性

    w3c中文版(html5、css、ajax、asp、js、dhtml)

    本节为必须对关键业务程序重新启用 HTML 帮助 ActiveX 控件的管理员提供了一些示例。这些替代方法可能会危及计算机,使之更容易遭受上述安全更新所克制的威胁。最安全的做法是不要使用注册表替代方法。如果必须使用...

    ActionScript开发技术大全

    3.6.9E4X操作符 49 3.7条件语句 50 3.7.1if…else语句 50 3.7.2switch语句 53 3.8循环语句 55 3.8.1while语句 55 3.8.2do…while语句 56 3.8.3for语句 56 3.8.4for…in语句 57 3.8.5foreach…in语句 58 3.8.6break与...

    ObjectPath:半结构化数据的敏捷查询语言

    对象路径 用于半结构化数据的敏捷NoSQL查询语言 #Python #NoSQL #Javascript #JSON#... 它借鉴了E4X,JSONPath,XPath和SQL的优点。 ObjectPath是JSON文档,XPath是XML。 说明这种关系的其他示例是: 范围 语 文字

    Mvc图片文件上传组件

    原创 Eaglet.dll 为图片上传组件 Eaglet.xml 为注释文件 本组件支持MVC,使用方法:右键MVC项目的“引用”——添加引用——浏览——找到并添加eaglet.dll 使用方法见示例程序MvcWebControlsTest

Global site tag (gtag.js) - Google Analytics