Check out the Latest Articles:

One of the best improvements of AS3 is the inclusion of native support for parsing xml with e4x. E4X give us the possibility of parsing xml data as objects.

You can access the information using “dot” notation ie node_name.node_child_node_child…

As any technology there are advantatges and disadvantatges:

Advantatges:

This technology is fast to write, very intuitive and saves a lot of typing.

Disadvantatges:

You must be careful about what are you filtering, large xml means an increasing of flash player time to parse the file, which is stored in memory temporarely, and this is a quite important performance issue.

In the next example you can find how can you filter a xml file using this technique:

[SWF]wp-blogfiles/bin-release/regex.swf, 500, 576[/SWF]

And here some code:

private var _xml:XML;		

private function init():void
{
        loadXML("../assets/XML/texts.xml");
}

private function loadXML(xml:String):void
{
        var loader:URLLoader = new URLLoader();
	loader.addEventListener(Event.COMPLETE, handler_xmlIsLoadedCorrectly);
	loader.dataFormat = "e4x"
	loader.load(new URLRequest(xml));
}

private function handler_xmlIsLoadedCorrectly(event:Event):void
{
	_xml = new XML(event.target.data);
	TA_Xml.text = _xml.toString()
}

private function handler_searchStringIsChanged(event:Event):void
{
	var reg:RegExp = new RegExp(TI_SearchString.text);
	TI_Results.text = _xml..item.(reg.test(text)).@id
}

I hope you find it useful!

VN:F [1.9.7_1111]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.7_1111]
Rating: +1 (from 1 vote)
Flex 3, e4x, xml and filtering using Regular expressions (regExp), 10.0 out of 10 based on 1 rating

Related posts:

  1. Flex swf optimization ( I )
  2. Flex, Amazon S3 and custom headers
  3. Compile CSS to SWF memory bottleneck
  4. Creating your first BlazeDS project


  1. Kenneth (Reply) on Monday 22, 2008

    Check your RSL location. The app above can’t find them.
    404 on http://blog.ncatstudios.com/framework_3.1.0.2710.swz

    Error #2032: Stream Error. URL: framework_3.1.0.2710.swf

    VA:F [1.9.7_1111]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.7_1111]
    Rating: 0 (from 0 votes)

Spam Protection by WP-SpamFree