XML,命名空间和E4X [英] XML, namespaces and E4X

查看:161
本文介绍了XML,命名空间和E4X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能解释我是什么在XML命名空间完全相同(的xmlns =...)是和他们如何在导航使用E4X(.. preferrably在ActionScript 3)XML使用?

Can someone explain me what exactly namespaces (xmlns="...") in XML are for and how they have to be used in navigating an XML using E4X (..preferrably in ActionScript 3)?

我不完全理解他们的用途和用法。

I fail to fully understand their purpose and usage.

推荐答案

在理论上,XML命名空间是用来避免与标签名称冲突。所以,我可以创建一个包含一个名为MyTag的和别人标签创建一个不同的命名空间具有相同标记MyTag的,并不会有任何冲突的命名空间。每个MyTag的标签将有明显区分。

In theory, XML namespaces are used to avoid conflict with tag names. So I can create a namespace that contains a tag named "mytag" and someone else creates a different namespace with the same tag "mytag" and there won't be any conflict. Each "mytag" tag will be clearly differentiated.

在实践中,我发现,XML命名空间是pretty的无用(你经常有两个开发人员创建标签相同的XML文件?),只是做了解析烦人困难。

In practice, I found that XML namespaces are pretty much useless (how often do you have two developers creating tag for the same XML file?) and just make the parsing annoyingly difficult.

在EX4,你需要得到的命名空间,那么preFIX与命名空间的每一个标签。因此,举例来说,如果你要访问的标签< somenamespace :: somename> ,你会写:

In EX4, you'll need to get the namespace, then prefix each tag with that namespace. So, for example, if you want to access the tag <somenamespace::somename> you will write:

var somenamespace:Namespace = xml.namespace("somenamespace");
var sometag:XML = somenamespace::somename[0];

如果你在谷歌搜索,你会发现,删除XML这些无用的命名空间的一些AS3类,使分析更容易。

If you search on Google, you'll find some AS3 classes that remove these useless namespaces from XML to make parsing easier.

这篇关于XML,命名空间和E4X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆