e4x

Howto convert E4X XML Elements into JSON Notation [duplicate]

末鹿安然 提交于 2019-12-11 01:42:58
问题 This question already has answers here : Convert XML to JSON (and back) using Javascript (10 answers) Closed 5 years ago . I have a server Implementation of ECMA Script including the ability to use E4X. Because this is pretty elegant for people don't know JavaScript and JSON Notation and we want to make an API which is most easy to learn i want to use this for my API. I'm currently evaluating if i can use this in my environment. One Showstopping feature that i must use is to convert those XML

Can E4X Get Attribute of a Parent Node Based on Attribute of a Child At Any Level?

别说谁变了你拦得住时间么 提交于 2019-12-10 17:37:40
问题 Consider this XML snippet with "nodes" which can have unlimited child levels of "subnode" elements. I want to find @type attribute of the node for any given subnode , based on its @id attribute. For example, if I have an id of 9 then I want to return the type="foo" from above. <xml> <node type="bar"> <subnode id="4"> <subnode id="5"/> </subnode> <subnode id="6"/> </node> <node type="foo"> <subnode id="7"> <subnode id="8"> <subnode id="9"/> </subnode> </subnode> <subnode id="10"/> </node> <

Programatically enable/disable menuBar buttons in Flex 4

我是研究僧i 提交于 2019-12-10 16:38:31
问题 I have the following XML in my Flex4 (AIR) project that defines the start of my menu interface: <mx:MenuBar x="0" y="0" width="100%" id="myMenuBar" labelField="@label" itemClick="menuChange(event)"> <mx:dataProvider> <s:XMLListCollection> <fx:XMLList xmlns=""> <menu label="File"> <item label="New"/> <item label="Load"/> <item label="Save" enabled="false"/> </menu> <menu label="Help"> <item label="About"/> </menu> </fx:XMLList> </s:XMLListCollection> </mx:dataProvider> </mx:MenuBar> I am

E4X select Nodes where descendants can be either A OR B or A && B

£可爱£侵袭症+ 提交于 2019-12-10 15:33:49
问题 So I have this XML structure: <Items> <Item name="aaa"> <ProductRanges> <ProductRange id="1" /> </ProductRanges> </Item> <Item name="bbb"> <ProductRanges> <ProductRange id="2" /> </ProductRanges> </Item> <Item name="ccc"> <ProductRanges> <ProductRange id="1" /> <ProductRange id="2" /> </ProductRanges> </Item> </Items> Using the following E4X query I get only item "aaa" and item "bbb". trace( Items.Item.(descendants("ProductRange").@id == "1" || descendants("ProductRange").@id == "2") );

Proper way to replace text in E4X element

做~自己de王妃 提交于 2019-12-08 02:41:10
问题 I'm trying to remove double quotes from text nodes. The following code works: var cars = <cars> <buick> <color> "Blue" </color> </buick> <chevy> <color> "Red" </color> </chevy> </cars>; for each (elem in cars) for each (item in elem.*) elem[item.localName()] = item.text().toString().replace(/"/g,''); However, I don't feel comfortable about the elem[item.localName()]= construction. Indeed, I already have a pointed to text item and it would be much more logical to use something like: item =

What is the Flex/AS3/E4X equivalent of this xpath query?

不打扰是莪最后的温柔 提交于 2019-12-07 11:22:21
问题 Given this document: <doc> <element> <list> <key attr='val'/> </list> </element> <element> <list> <key attr='other'/> </list> </element> <element> <list/> </element> </doc> I want an e4x equivalent of the xpath //element[list/key/@attr="val"] . Is it possible to do that? 回答1: ..element.(list.key.@attr == "val") 回答2: xmlVarName.element.list.key.(@attr=="val"); alternative xmlVarName..key.(@attr=="val"); 回答3: It is important to note that ..element.(list.key.@attr == "val") Can fail if the key

Proper way to replace text in E4X element

只愿长相守 提交于 2019-12-06 12:13:00
I'm trying to remove double quotes from text nodes. The following code works: var cars = <cars> <buick> <color> "Blue" </color> </buick> <chevy> <color> "Red" </color> </chevy> </cars>; for each (elem in cars) for each (item in elem.*) elem[item.localName()] = item.text().toString().replace(/"/g,''); However, I don't feel comfortable about the elem[item.localName()]= construction. Indeed, I already have a pointed to text item and it would be much more logical to use something like: item = item.text().toString().replace(/"/g,''); Unfortunately, this code doesn't seem to do what it's supposed to

E4X Add CDATA content

情到浓时终转凉″ 提交于 2019-12-05 21:24:01
问题 Basically I need to define a node name and its CDATA content using variables. var nodeName:String = "tag"; var nodeValue:String = "<non-escaped-content>"; Naively I thought this would work : var xml:XML = <doc><{nodeName}><![CDATA[{nodeValue}]]></{nodeName}> Outputs : <doc><tag><![CDATA[{nodeValue}]]></tag></doc> In a previous version of the script designed for FP9 I bypassed the problem by using : new XMLNode( XMLNodeType.XMLNodeType.CDATA_NODE, nodeValue ); // ... but this doesn't seem to

Actionscript 3 E4X working with namespace values in XML

♀尐吖头ヾ 提交于 2019-12-02 10:26:55
问题 I am building an application using Action script 3 I am retrieving some XML from the web however the node names are mms:Image mms:Results etc my action script compiler is throwing an error becuase it is not expecting to see the semi colon in the node name. How to I access the nodes? thanks 回答1: Those are XML namespaces and they can be a pain to use. Have a look at the Adobe documentation on Using XML namespaces. Basically you have to get the namespace: var mmsNS:Namespace = message.namespace(

Actionscript 3 E4X working with namespace values in XML

三世轮回 提交于 2019-12-02 04:26:32
I am building an application using Action script 3 I am retrieving some XML from the web however the node names are mms:Image mms:Results etc my action script compiler is throwing an error becuase it is not expecting to see the semi colon in the node name. How to I access the nodes? thanks James Fassett Those are XML namespaces and they can be a pain to use. Have a look at the Adobe documentation on Using XML namespaces . Basically you have to get the namespace: var mmsNS:Namespace = message.namespace("mms"); // alternatively for nested namespaces: var mmsNS:Namespace = new Namespace("mms", "