- 浏览: 1045430 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (538)
- 奇文共赏 (36)
- spring (13)
- hibernate (10)
- AOP/Aspectj (9)
- spring security (7)
- lucence (5)
- compass (3)
- jbmp (2)
- jboss rule(drools) (0)
- birt (1)
- jasper (1)
- cxf (3)
- flex (98)
- webgis (6)
- 设计模式 (1)
- 代码重构 (2)
- log4j (1)
- tomcat (9)
- 神品音乐 (1)
- 工作计划 (2)
- appfuse (1)
- svn (4)
- 寻章摘句 (3)
- eclipse (10)
- arcgis api for flex (1)
- 算法 (5)
- opengis-cs (1)
- bug心得 (13)
- 图标 (1)
- software&key (14)
- java (17)
- 搞笑视频 (13)
- sqlserver (9)
- postgresql (1)
- postgis (0)
- geoserver (5)
- 日子 (50)
- 水晶报表 (1)
- 绝对电影 (3)
- Alternativa3D (1)
- 酷站大全 (10)
- c++ (5)
- oracle (17)
- oracle spatial (25)
- flashbuilder4 (3)
- TweenLite (1)
- DailyBuild (6)
- 华山论贱 (5)
- 系统性能 (5)
- 经典古文 (6)
- SOA/SCA/OSGI (6)
- jira (2)
- Hadoop生态圈(hadoop/hbase/pig/hive/zookeeper) (37)
- 风水 (1)
- linux操作基础 (17)
- 经济 (4)
- 茶 (3)
- JUnit (1)
- C# dotNet (1)
- netbeans (1)
- Java2D (1)
- QT4 (1)
- google Test/Mock/AutoTest (3)
- maven (1)
- 3d/OSG (1)
- Eclipse RCP (3)
- CUDA (1)
- Access control (0)
- http://linux.chinaunix.net/techdoc/beginner/2008/01/29/977725.shtml (1)
- redis (1)
最新评论
-
dove19900520:
朋友,你确定你的标题跟文章内容对应???
tomcat控制浏览器不缓存 -
wussrc:
我只想说牛逼,就我接触过的那点云计算的东西,仔细想想还真是这么 ...
别样解释云计算,太TM天才跨界了 -
hw_imxy:
endpoint="/Hello/messagebr ...
flex+java代码分两个工程 -
gaohejie:
rsrsdgrfdh坎坎坷坷
Flex 与 Spring 集成 -
李涤尘:
谢谢。不过说得有点太罗嗦了。
Oracle数据库数据的导入及导出(转)
http://joshblog.net/2007/06/29/getting-advanced-with-e4x/
Sometimes, when working with XML from webservices or public APIs, you will encounter certain elements or attributes in namespaces. For instance, the Yahoo! Weather RSS Feed has a yweather namespace that adds certain new elements to the feed that aren't part of the regular RSS standard. To use E4X with complex XML like this, you'll need to know a couple of things to make this namespaced data accessible.
For the following examples, I will be using the Yahoo! Weather feed for Sunnyvale, CA. It is available at the following URL:
http://weather.yahooapis.com/forecastrss?p=94089.
There are two ways to use namespaces in your E4X statements. You can reference the namespace directly in your query, or you can declare the namespace available for use globally. Regardless of which method you use, you'll need to declare the namespace first. Notice that it is defined by a URL. I've taken this value directly from its declaration in the RSS feed itself.
SWITCH TO PLAIN TEXT
Actionscript:
namespace yweather = "http://xml.weather.yahoo.com/ns/rss/1.0";
First, let's access the current temperature using the namespace inline:
SWITCH TO PLAIN TEXT
Actionscript:
var temp:int = rss.channel.item.yweather::condition.@temp;
It's simple, but as you can probably imagine, a complex query will require too many references to the namespace. Alternatively, if you don't want to litter your queries references to yweather::, you can tell the compiler to use this namespace globally.
SWITCH TO PLAIN TEXT
Actionscript:
use namespace yweather;
Now, we can write a simpler E4X query without the need to worry about our namespace:
SWITCH TO PLAIN TEXT
Actionscript:
var temp:int = rss.channel.item.condition.@temp;
Now, let's look at the condition element in the feed a little bit differently. For debug purposes, let's trace a few values to the console. Notice that we can get the string representation of the attribute's name very easily through, you guessed it, the name() function.
SWITCH TO PLAIN TEXT
Actionscript:
var attributes:XMLList = rss.channel.item.condition.attributes();
var count:int = attributes.length();
for( var i:int = 0; i <count; i++ )
{
var attribute:XML = attributes[ i ];
trace( attribute.name(), attribute );
}
You can see that when you access an attribute from an element, you're actually getting a new XML object. When most people think of objects of this type, they expect to see an element, but it can hold many different forms of XML data. If you'd like to learn more, check out the documentation for the XML class, and its nodeKind() function in particular. You'll discover that an XML object can hold simple text, comments (<!-- comment -->), attributes, elements, and processing instructions.
Let's finish up with the sample XHTML document that I referenced in my second post about E4X.
SWITCH TO PLAIN TEXT
Actionscript:
var html:XML = <html>
<body>
<ul class="links">
<li><a href="http://www.yahoo.com/" class="josh">Yahoo!</a></li>
<li><a href="http://www.adobe.com/">Adobe</a></li>
<li><a href="http://www.zeuslabs.us/" class="josh">Zeus Labs</a></li>
</ul>
<div id="intro">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</body>
</html>;
I recently discovered that if you try to reference an attribute that doesn't exist, you'll get a runtime error. For example, try to get the all the anchors (links) in the above document with a class named "josh". It doesn't work (without some extra massaging, as you'll see below) because the link to Adobe doesn't have a class attribute at all.
SWITCH TO PLAIN TEXT
Actionscript:
var anchors:XMLList = html.body..a.(@["class"] == "josh");
//error
What you can do to get around this problem is to use the hasOwnProperty() function available to all Objects. This will allow us to first check to see if the class attribute exists, and if it doesn't, it will skip that particular anchor thanks to the short-circuiting of the && operator.
SWITCH TO PLAIN TEXT
Actionscript:
var anchors:XMLList = html.body..a.(hasOwnProperty("@class") && @["class"] == "josh");
I expected that my first two posts about E4X (1, 2) would cover most of the important details. However, only a couple days after I finished the second one, I had already started remembering more features to explore and share. Will there be more? I don't have anything planned, but I won't be surprised if I discover a couple cool new techniques eventually.
发表评论
-
ActionScript 3.0 性能优化小知识
2010-07-30 14:12 1032http://xinsync.xju.edu.cn/in ... -
Flex企业级UI权限控制
2010-07-28 16:14 1302http://www.pin5i.com/showtopic- ... -
flex4中PopUpManager在module中有问题
2010-06-24 11:10 3142flex4中module加载module后flex4中 a ... -
Flex 开发: 类的反射
2010-06-24 10:56 1269http://www.ibm.com/developerwor ... -
Problems with ByteArray.writeObject()
2010-05-19 21:47 1725http://www.actionscript.org/for ... -
利用 E4X解决 XML 处理的性能问题
2010-05-19 21:11 1752http://www.blogjava.net/rosen/a ... -
正在安装的adobe flash player版本不是最新的版本
2010-04-22 09:56 2457打开注册表编辑器,定位到HKEY_LOCAL_MACHINE\ ... -
AS3 优化 之 FOR内循环
2010-02-10 15:39 1564写游戏只要有思路,就能实现,但这也只是从功能角度出发,能不能有 ... -
flex模块切换时导致对象不正确序列化的解决办法
2009-12-02 09:08 1628http://lkfnn.iteye.com/blog/506 ... -
漂亮的登陆
2009-11-19 16:32 1160http://dougmccune.com/360Flex_A ... -
Download all 177 Flash Effects Source Files .fla
2009-11-13 09:27 1223http://www.jeffjoneslive.com/Fl ... -
flex如何接受其他页面Post过来的数据
2009-10-10 11:15 2558问题描述: 有个程序需要调用我的flex页面,需要给我传 ... -
Change font size in the whole app with Ctrl+/-
2009-10-09 10:06 1202http://feedproxy.google.com/~r/ ... -
flex delete关键词和类成员
2009-10-09 09:01 1408flash中delete关键词用来移除定义的变量,并不能从内存 ... -
Flex HTTPService如何给后台传递参数
2009-10-09 08:56 1525http://blog.csdn.net/joeyshi/ar ... -
FLEX Builder compiler arguments 的设置
2009-09-28 08:20 1656http://flash.9ria.com/thread-18 ... -
12 Best Adobe AIR Applications for Web Designers
2009-09-25 08:20 107812 Best Adobe AIR Applications ... -
做网页如何改变IE地址栏的显示IE图标
2009-09-23 16:55 2701这个问题的解决其实在flex之外 修改index.templa ... -
Flex设置html(页面标题)title问题
2009-09-23 15:31 3287如果你是一个整体系统用了同一个标题:可以修改模板页index. ... -
flex中文问题,访问中文路径问题
2009-09-23 14:36 1202本文最先发表在本人个 ...
相关推荐
Getting Started with Processing is not a programming textbook; as the title suggests, it will get you started. It’s for teenagers, hobbyists, grandparents, and everyone in between. This book is also...
Written by electronics guru Simon Monk, Programming FPGAs: Getting Started with Verilog features clear explanations, easy-to-follow examples, and downloadable sample programs. You’ll get start-to-...
Getting started with Spring Framework (4th Edition) is a hands-on guide to begin developing applications using Spring Framework 5. The examples (consisting of 88 sample projects) that accompany this ...
《Getting Started with p5.js中文版》是一本针对初学者的p5.js教程,由Lauren McCarthy、Casey Reas和Ben Fry共同创作。p5.js是一个基于JavaScript的创意编程库,它的目标是使编程变得更为易用和包容,特别适合艺术...
getting started with Cplex. Cplex user guide
《getting start with storm》中译电子书
Getting Started With Arduino - 3rd Edition
蓝牙低功耗(Bluetooth Low Energy,简称BLE)是一种无线技术标准,用于设备近距离通信。它被设计用于在低功耗条件下传输数据,专为小型设备和应用程序而优化,这在智能穿戴设备、位置追踪器和其他物联网(IoT)设备...
Getting Started with Varnish Cache 2017.3英文版两个格式: 1. Getting.Started.with.Varnish.Cache.2017.3.epub 2. Getting.Started.with.Varnish.Cache.2017.3.azw3
There are a multitude of books out there to help you hone your Verification skills, as almost every Digital IC professional ...from advanced concepts (the Factory, register package prediction, etc.)
标题《ABAQUS 帮助文档—Getting started with ABAQUS.pdf》表明本文档是ABAQUS软件的入门级帮助指南,主要面向那些希望开始使用ABAQUS进行有限元分析的用户。文档的副标题“Keywords Edition”强调本指南侧重于...
Getting started with bluetooth low energy 低功耗蓝牙技术参考,比较通俗易懂
Getting Started with Arduino, 1st Edition By Massimo Banzi
Build Better Chatbots A Complete Guide to Getting Started with Chatbots 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
Getting Started With JUCE 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或...
This book will provide you with a good foundation so that you can successfully implement audio into your games and begin pursuing other advanced topics in audio programming with confidence. ...
《Getting Started with LLVM Core Libraries》是一本关于LLVM(Low Level Virtual Machine)核心库入门的书籍。LLVM是一套广泛使用的开源基础架构,专为编译器开发设计。本书详细阐述了LLVM核心库的安装过程、使用...
Packt Getting Started with Kubernetes 2nd Edition原版,高清英文版,用于学习 Kubernetes