﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Keith Hair &#187; E4X Filtering</title>
	<atom:link href="http://keith-hair.net/blog/tag/e4x-filtering/feed/" rel="self" type="application/rss+xml" />
	<link>http://keith-hair.net/blog</link>
	<description>Scripting is fun like any other hobby</description>
	<lastBuildDate>Sat, 28 Jan 2012 05:04:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Case-insensitive E4X filtering</title>
		<link>http://keith-hair.net/blog/2008/06/01/case-insensitive-e4x-filtering/</link>
		<comments>http://keith-hair.net/blog/2008/06/01/case-insensitive-e4x-filtering/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 15:13:57 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[E4X Filtering]]></category>
		<category><![CDATA[Regular Expressions]]></category>

		<guid isPermaLink="false">http://keith-hair.com/blog/?p=7</guid>
		<description><![CDATA[When I'm writing a script to read XML data, I personally like the identification of node names and attributes to be case-insensitive. Its one less thing to worry about when others are modifying the XML data that my script will have to read and render, and I think they feel modifying the XML to be [...]]]></description>
			<content:encoded><![CDATA[<p>When I'm writing a script to read XML data, I personally like the identification of node names and attributes to be case-insensitive. Its one less thing to worry about when others are modifying the XML data that my script will have to read and render, and I think they feel modifying the XML to be more user-friendly this way. <img src='http://keith-hair.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here, the example scripts pull a list of all the nodes with the name "MEDIA".<br />
Using Regular Expressions, you can identify each "MEDIA" node regardless of its letter case.</p>
<pre class="actionscript">&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> doc:<span style="color: #0066CC;">XML</span>=
&lt;DATA&gt;
	&lt;CATEGORY&gt;
		&lt;MEDIA&gt;A.<span style="color: #006600;">jpg</span>&lt;/MEDIA&gt;
		&lt;MEDIA&gt;B.<span style="color: #006600;">jpg</span>&lt;/MEDIA&gt;
	&lt;/CATEGORY&gt;
	&lt;CATEGORY&gt;
		&lt;MEDIA&gt;C.<span style="color: #006600;">jpg</span>&lt;/MEDIA&gt;
	&lt;/CATEGORY&gt;
	&lt;CATEGORY&gt;
		&lt;MEDIA&gt;D.<span style="color: #006600;">jpg</span>&lt;/MEDIA&gt;
	&lt;/CATEGORY&gt;
	&lt;CATEGORY&gt;
		&lt;MEDIA&gt;E.<span style="color: #006600;">jpg</span>&lt;/MEDIA&gt;
	&lt;/CATEGORY&gt;
&lt;/DATA&gt;;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> findName:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;media&quot;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>doc..<span style="color: #006600;">*</span>.<span style="color: #006600;"><span style="color: #66cc66;">&#40;</span></span><span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span>findName,<span style="color: #ff0000;">&quot;i&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;test&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toXMLString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p> <img src='http://keith-hair.net/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  <em>"Error #1069: Property lowerCase not found on QName"</em></p>
<pre class="actionscript">&nbsp;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>doc..<span style="color: #006600;">*</span>.<span style="color: #006600;"><span style="color: #66cc66;">&#40;</span></span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">lowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>==<span style="color: #ff0000;">&quot;media&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toXMLString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p> <img src='http://keith-hair.net/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  Letter case must be same for this to work.</p>
<pre class="actionscript">&nbsp;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>doc..<span style="color: #006600;">*</span>.<span style="color: #006600;"><span style="color: #66cc66;">&#40;</span></span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>==<span style="color: #ff0000;">&quot;MEDIA&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toXMLString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Used a regular expression to do case-insensitive filter<br />
 <img src='http://keith-hair.net/blog/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' />  Works, letter case does not matter...but the expression is too "hardcoded". </p>
<pre class="actionscript">&nbsp;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>doc..<span style="color: #006600;">*</span>.<span style="color: #006600;"><span style="color: #66cc66;">&#40;</span></span>/media/i.<span style="color: #006600;">test</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toXMLString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p> <img src='http://keith-hair.net/blog/wp-includes/images/smilies/icon_confused.gif' alt=':-?' class='wp-smiley' />  Works, but compiler does not like it:<br />
<em>"Warning: 3594: test is not a recognized method of the dynamic class RegExp."</em><br />
This is an attempt to allow variables and expressions.</p>
<pre class="actionscript">&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> findName:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;media&quot;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>doc..<span style="color: #006600;">*</span>.<span style="color: #006600;"><span style="color: #66cc66;">&#40;</span></span><span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span>findName,<span style="color: #ff0000;">&quot;i&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">test</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toXMLString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>:jumping: Works!<br />
"[" and "]" keeps the compiler from warning when using the RegExp "test()" method.<br />
Now letter case does not matter, and RegExp constructor allows variables or expressions.</p>
<pre class="actionscript">&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> findName:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;media&quot;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>doc..<span style="color: #006600;">*</span>.<span style="color: #006600;"><span style="color: #66cc66;">&#40;</span></span><span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span>findName,<span style="color: #ff0000;">&quot;i&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;test&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toXMLString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2008/06/01/case-insensitive-e4x-filtering/&ztz=Case-insensitive E4X filtering'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2008/06/01/case-insensitive-e4x-filtering/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using E4X with XML in AS3</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/</link>
		<comments>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/#comments</comments>
		<pubDate>Sat, 31 May 2008 15:54:09 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[E4X Filtering]]></category>
		<category><![CDATA[Regular Expressions]]></category>

		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5</guid>
		<description><![CDATA[The XML examples represent a book in a library. However the book has several bookworms in it. Using E4X we can find these bookworms. &#160; &#60;library&#62; &#60;book&#62; &#60;page id=&#34;one&#34;/&#62; &#60;worm name=&#34;Eddy&#34; /&#62; &#60;page id=&#34;two&#34;/&#62; &#60;page id=&#34;three&#34;&#62; &#60;worm name=&#34;Lisa&#34;/&#62; &#60;worm name=&#34;Pete&#34; /&#62; &#60;/page&#62; &#60;page id=&#34;four&#34;/&#62; &#60;/book&#62; &#60;/library&#62; &#160; There are some E4X operators and XML methods [...]]]></description>
			<content:encoded><![CDATA[<p>The  XML examples represent a book in a library. However the book has several bookworms in it.<br />
Using E4X we can find these bookworms.</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;library<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;one&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Eddy&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;two&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;three&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Lisa&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Pete&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/page<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;four&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/library<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>There are some E4X operators and XML methods to help use do this when combined together:</p>
<blockquote><p>
<strong>..</strong> Access all descendants of the XML object.<br />
<strong>.</strong> Access a property of an Object or XML.<br />
<strong>*</strong> Wildcard, match any part of the XML.<br />
<strong>childIndex()</strong> Index number of an XML object relative to its parent node.<br />
<strong>name()</strong> Name of the XML node.
</p></blockquote>
<p><span id="more-5"></span></p>
<p><strong>Return a certain "worm" node at the index it belongs to from its XMLList.<br />
Any nested "worm" node occurrence is also considered.</strong></p>
<pre class="xml">&nbsp;
var doc:XML=
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;library<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;one&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Eddy&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;two&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;three&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Lisa&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Pete&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/page<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;four&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/library<span style="font-weight: bold; color: black;">&gt;</span></span></span>;
&nbsp;
//Pick the &quot;worm&quot; node at index 1.
var data:*=doc..*.worm[1];
trace(data.toXMLString());
&nbsp;
/*=========================================
OUTPUT:
&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Lisa&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>			//worm[1]
===========================================*/
&nbsp;</pre>
<p><strong>Delete all "worm" nodes from the xml, even the nested ones.</strong></p>
<pre class="xml">&nbsp;
var doc:XML=
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;library<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;one&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Eddy&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;two&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;three&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Lisa&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Pete&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/page<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;four&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/library<span style="font-weight: bold; color: black;">&gt;</span></span></span>;
&nbsp;
delete doc..*.worm;
trace(doc.toXMLString());
&nbsp;
/*=========================================
OUTPUT:
All &quot;worm&quot; nodes are deleted.
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;library<span style="font-weight: bold; color: black;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;one&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;two&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;three&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;four&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/library<span style="font-weight: bold; color: black;">&gt;</span></span></span>
===========================================*/
&nbsp;</pre>
<p><strong><br />
Use E4X filtering with Regular Expressions.</strong><br />
XML methods and Regular Expressions can be used inside parentheses to accomplish E4X filtering.</p>
<blockquote><p>doc..*.(childIndex()==0 &amp;&amp; /library|book/i.test(name())==false)</p></blockquote>
<p><strong>List all nodes that belong at a given index of their XMLList.</strong></p>
<pre class="xml">&nbsp;
var doc:XML=
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;library<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;one&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Eddy&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;two&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;three&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Lisa&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Pete&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/page<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;four&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/book<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/library<span style="font-weight: bold; color: black;">&gt;</span></span></span>;
&nbsp;
//----------------------------------------------------
//Get the first node of each list whose name does not
//match the regular expression.
//----------------------------------------------------
var data:*=doc..*.(childIndex()==0 <span style="color: #ddbb00;">&amp;&amp; /library|book/i.test(name())==false);</span>
trace(data.toXMLString());
&nbsp;
/*=========================================
OUTPUT:
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;page</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;one&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;worm</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Lisa&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
===========================================*/
&nbsp;</pre>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/&ztz=Using E4X with XML in AS3'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

