Just wrapped my session at Adobe MAX on E4X. I think the session went well, although there were not as many questions during the session compared to the previous times I’ve given this topic. Don’t know if that means I’m getting better at covering the topic or losing the audience…
I did get several good questions at the very end of the session (post closing – so unfortunately it did not go on the recording).
The two followups I have from the session are on XSLT and data validation (XSD/DTD). Stay tuned for updates on those.
Presentation slides (warning, it is a big file -700k- because of the Adobe images):
http://www.rapidninja.com/blog/MAX2008/Marc_Bir_E4X.ppt
The code for the samples
http://www.rapidninja.com/blog/MAX2008/E4XSamples.zip
And finally the CSV2XML converter I used to create the Sessions XML file.
November 24, 2008 at 7:46 pm |
Hi Marc
I was present for your talk at MAX and I really liked the E4X filters part. I am trying to write a filter for the following XML.
var xml:XML =
<root xmlns:ns1="http://foo.bar.com">
<leaf ns1:attr="1">Hello</leaf>
<leaf>My</leaf>
<leaf ns1:attr="2">World</leaf>
</root>
I want to write a filter that will give me an XMLList for all leaf nodes that have the attribute ns1::attr. I need something like this:
xml.leaf.(@ns1::attr)
xml.leaf.(attribute(“ns1::attr”) != “”)
xml.leaf.(hasOwnProperty(“@ns1::attr”))
Second and third are incorrect since ns1 needs to be substituted by something appropriate. I have tried sticking the namespace string, but to no avail.
Thanks in advance
November 25, 2008 at 2:44 pm |
You will need something like:
var ns1: Namespace = new Namespace(‘http://foo.bar.com’);
var q: QName = new QName(ns1, ‘attr’);
xml.leaf.(attribute(q) >0));
I didn’t really go into any discussion on Namespace or QName in the presentation, but as you can see they are an absolute requirement when working with more than the most basic XML. You could also inline the entire expression as:
xml.leaf.(attribute(new QName(new Namespace(‘http://foo.bar.com’), ‘attr’)) >0));
That allows it to work in places like MXML databinding, but is far less readable.
I now have a todo for creating a blog entry on working with namespaces in E4X.
November 25, 2008 at 6:53 pm |
Thanks a lot for the solution. Works like a charm!
November 28, 2008 at 4:31 pm |
Marc,
I was at your Max session and while I know and have used E4X – I guess I have to admit that I did not really fully appreciate the power of E4X until I attended our session. I’ll put that down to my introduction to Actionscript and E4X at the same time. Well done on a great job presenting E4X. I suspect that you did not get many questions because you did a great job in explaining and demonstrating the concepts.
Dipock
February 15, 2009 at 7:35 am |
Marc,
I missed your session at Max, glad to see it in Adobe TV.
My question is on CDATA… I have not seen any documentation or examples covering CDATA.
How does one go about creating a node whose value is CDATA encapsulated and bound to another variable? as in:
var node:XML =
Flex does not bind {val} above to the variable contents…
I use a workaround trick to replace {val} above in runtime, like:
myXML.appendChild(XML(node.toXMLString.replace(‘{val}’,val)));
Is there a ‘right’ way to accomplish that, without having to resort to a hack lie above?
TIA
julio
March 6, 2009 at 6:09 am |
Hi Marc,
If you get a moment could you check the link to your ppt as im showing a file not found error
Many regards,
Eric
March 6, 2009 at 6:29 am |
Fixed! Seems wordpress converted the URL to a relative path. Thanks for point it out.