e4x

get the index of first element to mach a condition in an XMLListCollection Object.

I have an XMLListCollection object that contains items with an ID property. I want to find one particular item by id and then get it's index in the collection. This is done to be able to tell the comboBox (whose dataProvider is the XMLListCollection) the index of the item to display. ...

Is there a way to select a certain number of nodes using e4x in Flex?

Say for example, I have an XML file with 100 "person" nodes, and I want the first 30. Or possibly 51 - 100. Is there any way to do this with e4x syntax to return an XMLList? ...

JavaScript / Rhino: Can I use a regular expression in an E4X query to select certain nodes only?

Hi! I'm working on Rhino (Mirth), and I've got to process / parse an XML with the following structure: <root> <row> <foo-1 /> <foo-2 /> <foo-3 /> <foo-4 /> ... <bar-1 /> <bar-2 /> <bar-3 /> <bar-4 /> ... <something-else-1 /> <something-else-2 /> </row> </root> I want to get all the "foo" nodes only, avoiding the use of loops if possi...

Flex Tree Visit Indicators

How do I indicate the visit history on a flex tree component? I want to highlight the clicked/visited nodes to a different color and will not change after that, so that all the visited nodes will be one color. I tried adding an attribute to the underlying XML by var selected:XML=app.treeObj.selectedItem as XML; if(!selected.hasOwnProp...

Not adding a namespace when using xml.setNamespace()

Whenever I call xml.setNamespace(ns), the namespace of the element is set to ns, but ns is also added as another namespace with it's own prefix to the element. I would like to know how to stop the latter from happening (I'm okay with modifying XML.prototype.function::setNamespace) without defining @xmlns as I can't use E4X syntax. Altern...

How to check if an XMLList is empty in Flex

If I have an XMLList object in Flex, what is the proper way to check to see if the list is empty? Should I just compare the result of myList.length() > 0, myList.toString() != "" or try another method altogether? ...

How to close elements the HTML-way with e4x-generated XML?

Hi all. I'm using e4x to generate a HTML-snippet for my users which they can copy & paste into their blogs or web sites: var xml: XML = <object> <param name="..."></param> <param name="..."></param> <embed args="..."></embed> </object>; var html: String = xml.toXMLS...

Parsing AS3 XML objects

I am getting an object back from ASP.NET, and when tracing the XML it as follows: var xml:XML = new XML(event.message.body); trace(xml); I get the following output: <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://localhost:49329/"&gt; <string>One</str...

Creating a DOM NodeList

I'm implementing all of the optional E4X features described in ECMA-357 Annex A and I'm having trouble implementing domNodeList (§A.1.2 and §A.2.2). How would I create my own NodeList object? Even if I create a new XMLDocument and append every domNode() representation of the nodes in an XMLList, I still don't see how I could create a No...

Use Javascript E4X to selectively rename XML tags

I am using javascript to manipulate XML in a non-browser context (no DOM), and am looking for an E4X expression to rename a list of tags. For any given tag, I don't necessarily know ahead of time what it is called, and I only want to rename it if it contains a given substring. As I very contrived example, I may have: someXML = <Favouri...

Anything similar to E4X to find in/traverse JSON?

When for example returning JSON from a Google Spreadsheet, the object returned contains an array of entry objects (corresponding to rows in the spreadsheet). An entry can have a name like so: jsonObject.feed.entries[15].name = "xyz"; Can I easily return an entry with the name of "xyz" using shorhand notation (E4X) of some sort? thanks...

Problem parsing XML using e4X & Flex 3

I am having difficultly parsing an XML file using e4X. I can acquire information from the 'version' tag, but I cannot from any nested tags. Could someone please point out what I am doing wrong? Here is the XML: <NameOfRoot xmlns="http://www.theaddress.com/file"&gt; <version>1.0</version> <NameOfChild1> <NameOfChild2...

Mirth: overwriting msg object with contents in an XML object

The task is to send an XML object from Channel-A to Channel-B <MyMessage> <ID>42</ID> <hl7v2> MSH|^~\&|LAB|.... PID|1|.... </hl7v2> </MyMessage> The steps of the channel communication: in the Channel-B's source transformer, extract the HL7v2 contents OVERWRITE the current msg object in Channel-B with the extracted contents c...

XML attribute access in AS3

Hi, I have an xml file (loaded in with URLLoader) that looks like this: <?xml version="1.0" encoding="UTF-8"?> <root> <localizations> <words> <Brand us="Brand Here"></Brand> </words> </localizations> <world squareunits="100"></world> </root> Once loaded,what is the quickest way to access world.squareunits ...

Converting a simple XPath query to an E4X query

One might think the corresponding E4X query for the XPath query, //*[@foo = "bar"], would be ..*.(@foo == "bar"), but that will throw an error whenever it gets to an element without a foo attribute. I am currently using ..*.(function::valueOf().@foo == "bar") instead. My question is if there is another, less of a hack-way to do this. ...

Java: Ways to parse XML in E4X?

Hi, I was wondering if there was a way to parse XML using E4X, or something similar to E4X. Does such a framework / library exist? Thanks! ...

Flex e4x - select by multiple attributes

<EFM> <projects> <project name="EFM Columbus Supply Chain Project"> <characteristics> <characteristic name="Types of Data"> <textDescription></textDescription> <options> <option name="Commodity Flow" value="True"/> ...

AS3: Inserting XML Elements Alphabetically By A Property

So I'm having a slightly tricky issue... I'm generating an XML file within a class I'm writing. Let's say this was the starting XML: <base> <container id="0"> <element type="Image" x="0" y"0" /> <element type="Image" x="100" y"0" /> <container/> </base> I want to add additional <element>'s. The first order of...

Why does this XML query not work?

Heres some code for a test case. I don't understand why the first two queries produce a result but the third one doesn't. Any ideas? <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onInit();" > <mx:Script> <![CDATA[ private function onInit...

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

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 i...