﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Using E4X with XML in AS3</title>
	<atom:link href="http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/</link>
	<description>Scripting is fun like any other hobby</description>
	<lastBuildDate>Wed, 28 Jul 2010 10:17:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Rick</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/comment-page-1/#comment-674</link>
		<dc:creator>Rick</dc:creator>
		<pubDate>Tue, 27 Apr 2010 14:20:48 +0000</pubDate>
		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5#comment-674</guid>
		<description>Ah thanks Keith, very interesting. I&#039;ll try it that way.</description>
		<content:encoded><![CDATA[<p>Ah thanks Keith, very interesting. I&#8217;ll try it that way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith H</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/comment-page-1/#comment-673</link>
		<dc:creator>Keith H</dc:creator>
		<pubDate>Tue, 27 Apr 2010 06:01:30 +0000</pubDate>
		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5#comment-673</guid>
		<description>Rick,

Even though you can use delete with a hardcoded E4X syntax like &quot;delete doc.worm&quot;, using &quot;delete&quot; with an E4X expression always returns a runtime errors.
I personally feel it&#039;s better to let the &quot;delete&quot; operator work on individual nodes.
&quot;delete&quot; will always work on an XML child. Note the use of this WHILE loop and accessing the XML child with brackets, instead of XMLList.

var search:String=&quot;worm&quot;;
while(doc..*.(name() == search).length() &gt; 0)
{
	delete doc..*.(name() == search)[0];
}</description>
		<content:encoded><![CDATA[<p>Rick,</p>
<p>Even though you can use delete with a hardcoded E4X syntax like &#8220;delete doc.worm&#8221;, using &#8220;delete&#8221; with an E4X expression always returns a runtime errors.<br />
I personally feel it&#8217;s better to let the &#8220;delete&#8221; operator work on individual nodes.<br />
&#8220;delete&#8221; will always work on an XML child. Note the use of this WHILE loop and accessing the XML child with brackets, instead of XMLList.</p>
<p>var search:String=&#8221;worm&#8221;;<br />
while(doc..*.(name() == search).length() > 0)<br />
{<br />
	delete doc..*.(name() == search)[0];<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/comment-page-1/#comment-672</link>
		<dc:creator>Rick</dc:creator>
		<pubDate>Tue, 27 Apr 2010 04:07:21 +0000</pubDate>
		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5#comment-672</guid>
		<description>(trying this again escaping xml)

This still has me so freakin&#039; confused.
Convert your xml doc to the following, which is valid xml (no surrounding book node):

var doc:XML=
&lt;library&gt;
	&lt;page id=&quot;one&quot;/&gt;
		&lt;worm name=&quot;Eddy&quot; /&gt;
	&lt;page id=&quot;two&quot;/&gt;
	&lt;page id=&quot;three&quot;&gt;
		&lt;worm name=&quot;Lisa&quot;/&gt;
		&lt;worm name=&quot;Pete&quot; /&gt;
	&lt;/page&gt;
	&lt;page id=&quot;four&quot;/&gt;
	&lt;worm name=&quot;John&quot;/&gt;
	&lt;worm name=&quot;bill&quot;&gt;
		&lt;worm name=&quot;Sally&quot;/&gt;
		&lt;worm name=&quot;Fred&quot;/&gt;
	&lt;/worm&gt;
&lt;/library&gt;;


Now after you do:

delete doc..*.worm;

you end up with:

 doc =&lt;library&gt;
  &lt;page id=&quot;one&quot;/&gt;
  &lt;worm name=&quot;Eddy&quot;/&gt;
  &lt;page id=&quot;two&quot;/&gt;
  &lt;page id=&quot;three&quot;/&gt;
  &lt;page id=&quot;four&quot;/&gt;
  &lt;worm name=&quot;John&quot;/&gt;
  &lt;worm name=&quot;bill&quot;/&gt;
&lt;/library&gt;
???? How do I delete all &quot;worm&quot; nodes?

If I throw in another delete of delete doc.worm; after doing the initial delete, it works, but there should be a way to say &quot;all nodes&quot; where ever they are (which is what I thought delete doc..*.worm was doing????</description>
		<content:encoded><![CDATA[<p>(trying this again escaping xml)</p>
<p>This still has me so freakin&#8217; confused.<br />
Convert your xml doc to the following, which is valid xml (no surrounding book node):</p>
<p>var doc:XML=<br />
&lt;library&gt;<br />
	&lt;page id=&#8221;one&#8221;/&gt;<br />
		&lt;worm name=&#8221;Eddy&#8221; /&gt;<br />
	&lt;page id=&#8221;two&#8221;/&gt;<br />
	&lt;page id=&#8221;three&#8221;&gt;<br />
		&lt;worm name=&#8221;Lisa&#8221;/&gt;<br />
		&lt;worm name=&#8221;Pete&#8221; /&gt;<br />
	&lt;/page&gt;<br />
	&lt;page id=&#8221;four&#8221;/&gt;<br />
	&lt;worm name=&#8221;John&#8221;/&gt;<br />
	&lt;worm name=&#8221;bill&#8221;&gt;<br />
		&lt;worm name=&#8221;Sally&#8221;/&gt;<br />
		&lt;worm name=&#8221;Fred&#8221;/&gt;<br />
	&lt;/worm&gt;<br />
&lt;/library&gt;;</p>
<p>Now after you do:</p>
<p>delete doc..*.worm;</p>
<p>you end up with:</p>
<p> doc =&lt;library&gt;<br />
  &lt;page id=&#8221;one&#8221;/&gt;<br />
  &lt;worm name=&#8221;Eddy&#8221;/&gt;<br />
  &lt;page id=&#8221;two&#8221;/&gt;<br />
  &lt;page id=&#8221;three&#8221;/&gt;<br />
  &lt;page id=&#8221;four&#8221;/&gt;<br />
  &lt;worm name=&#8221;John&#8221;/&gt;<br />
  &lt;worm name=&#8221;bill&#8221;/&gt;<br />
&lt;/library&gt;<br />
???? How do I delete all &#8220;worm&#8221; nodes?</p>
<p>If I throw in another delete of delete doc.worm; after doing the initial delete, it works, but there should be a way to say &#8220;all nodes&#8221; where ever they are (which is what I thought delete doc..*.worm was doing????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith H</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/comment-page-1/#comment-629</link>
		<dc:creator>Keith H</dc:creator>
		<pubDate>Wed, 24 Mar 2010 00:03:39 +0000</pubDate>
		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5#comment-629</guid>
		<description>Dave, Looks like the  characters were cut off,
anyway if &quot;author&quot; is an attribute, you can do the following...

var bookList:XMLList = bookInput.Book.(attribute(&quot;author&quot;) == “some dude” );//returns an XMLList
var item:XML=bookList[0]; //Is this the actual child XML or &quot;item&quot; you are looking for?

//If need to delete it...
delete bookList[0];</description>
		<content:encoded><![CDATA[<p>Dave, Looks like the  characters were cut off,<br />
anyway if &#8220;author&#8221; is an attribute, you can do the following&#8230;</p>
<p>var bookList:XMLList = bookInput.Book.(attribute(&#8220;author&#8221;) == “some dude” );//returns an XMLList<br />
var item:XML=bookList[0]; //Is this the actual child XML or &#8220;item&#8221; you are looking for?</p>
<p>//If need to delete it&#8230;<br />
delete bookList[0];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dave</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/comment-page-1/#comment-628</link>
		<dc:creator>dave</dc:creator>
		<pubDate>Tue, 23 Mar 2010 22:19:30 +0000</pubDate>
		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5#comment-628</guid>
		<description>thanx this has been very helpful.  I do have one question I cant seem to find an answer to.  Say I have an xml


   
      good book
      some dude
   
   
      badbook
      bill man
   
   
      soso book
      jane dow
   


and I have want to find an item in that xml

var bookList:XMLList = bookInput.Book.(author == &quot;some dude&quot; );
trace(bookList);

easy enough but now I need to know what the index value is of that node so for example I can delete it or something else. How do I get that ??

thanx</description>
		<content:encoded><![CDATA[<p>thanx this has been very helpful.  I do have one question I cant seem to find an answer to.  Say I have an xml</p>
<p>      good book<br />
      some dude</p>
<p>      badbook<br />
      bill man</p>
<p>      soso book<br />
      jane dow</p>
<p>and I have want to find an item in that xml</p>
<p>var bookList:XMLList = bookInput.Book.(author == &#8220;some dude&#8221; );<br />
trace(bookList);</p>
<p>easy enough but now I need to know what the index value is of that node so for example I can delete it or something else. How do I get that ??</p>
<p>thanx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dominic</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/comment-page-1/#comment-166</link>
		<dc:creator>Dominic</dc:creator>
		<pubDate>Tue, 27 Jan 2009 17:01:22 +0000</pubDate>
		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5#comment-166</guid>
		<description>You&#039;re awesome. That &quot;[&quot; &quot;]&quot; solution for the warning of RegExp .test fixed my warnings. Thanks!

Dom</description>
		<content:encoded><![CDATA[<p>You&#8217;re awesome. That &#8220;[" "]&#8221; solution for the warning of RegExp .test fixed my warnings. Thanks!</p>
<p>Dom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Calvin</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/comment-page-1/#comment-148</link>
		<dc:creator>Calvin</dc:creator>
		<pubDate>Sat, 22 Nov 2008 09:00:54 +0000</pubDate>
		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5#comment-148</guid>
		<description>Yeah it doesn&#039;t really seem too logical does it? Just think that I must be missing some trick here, but there you go!

I think typeof will return &#039;XML&#039; no matter if it&#039;s XML or XMLList every time - you know like typeof on an Array is always &#039;object&#039;, but it is interesting that using &#039;is&#039; gives false for is XML, true for is XMLList - yet you can delete (i.e. no error #1119) when the XMLList wasn&#039;t made using a filter. Really weird.

Ah well, looping it is! For now...</description>
		<content:encoded><![CDATA[<p>Yeah it doesn&#8217;t really seem too logical does it? Just think that I must be missing some trick here, but there you go!</p>
<p>I think typeof will return &#8216;XML&#8217; no matter if it&#8217;s XML or XMLList every time &#8211; you know like typeof on an Array is always &#8216;object&#8217;, but it is interesting that using &#8216;is&#8217; gives false for is XML, true for is XMLList &#8211; yet you can delete (i.e. no error #1119) when the XMLList wasn&#8217;t made using a filter. Really weird.</p>
<p>Ah well, looping it is! For now&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith H</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/comment-page-1/#comment-147</link>
		<dc:creator>Keith H</dc:creator>
		<pubDate>Sat, 22 Nov 2008 01:10:26 +0000</pubDate>
		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5#comment-147</guid>
		<description>I&#039;d like more info on it too.

I think it&#039;s safe to say you can&#039;t delete an E4X expression operator &quot;()&quot;, but you can delete an XML node of it.
and all of the nodes nested in that node....by using [index] bracket operator on it

Yep its strange. The return datatype of this syntax &quot;doc..*.worm&quot;  is an XMLList.

doc..*.worm  //technically this is XMLList but delete works when the E4X syntax DOES NOT have an expression.
doc..*.(name()==&quot;worm&quot;) //The return type is XMLList and delete does not work with XMLList.
doc..*.(name()==&quot;worm&quot;)[0] //The return type is XML and delete works for XML.

The &quot;Expression&quot; part of E4X syntax always returns an XMLList.
The delete operator does not work with XMLList.
delete doc..*.(name()==&quot;worm&quot;);//TypeError: Error #1119: Delete operator is not supported

More strange confusion when I test:

trace(&quot;Testing &#039;typeof&#039;&quot;);
trace(typeof doc..*.worm); //says its XML an not XMLList
trace(typeof doc..*.(name()==&quot;worm&quot;)); //also says its XML an not XMLList
trace(&quot;&quot;);
trace(&quot;Testing &#039;is&#039;&quot;);
trace(doc..*.worm is XML);
trace(doc..*.(name()==&quot;worm&quot;) is XML);
trace(&quot;&quot;);</description>
		<content:encoded><![CDATA[<p>I&#8217;d like more info on it too.</p>
<p>I think it&#8217;s safe to say you can&#8217;t delete an E4X expression operator &#8220;()&#8221;, but you can delete an XML node of it.<br />
and all of the nodes nested in that node&#8230;.by using [index] bracket operator on it</p>
<p>Yep its strange. The return datatype of this syntax &#8220;doc..*.worm&#8221;  is an XMLList.</p>
<p>doc..*.worm  //technically this is XMLList but delete works when the E4X syntax DOES NOT have an expression.<br />
doc..*.(name()==&#8221;worm&#8221;) //The return type is XMLList and delete does not work with XMLList.<br />
doc..*.(name()==&#8221;worm&#8221;)[0] //The return type is XML and delete works for XML.</p>
<p>The &#8220;Expression&#8221; part of E4X syntax always returns an XMLList.<br />
The delete operator does not work with XMLList.<br />
delete doc..*.(name()==&#8221;worm&#8221;);//TypeError: Error #1119: Delete operator is not supported</p>
<p>More strange confusion when I test:</p>
<p>trace(&#8220;Testing &#8216;typeof&#8217;&#8221;);<br />
trace(typeof doc..*.worm); //says its XML an not XMLList<br />
trace(typeof doc..*.(name()==&#8221;worm&#8221;)); //also says its XML an not XMLList<br />
trace(&#8220;&#8221;);<br />
trace(&#8220;Testing &#8216;is&#8217;&#8221;);<br />
trace(doc..*.worm is XML);<br />
trace(doc..*.(name()==&#8221;worm&#8221;) is XML);<br />
trace(&#8220;&#8221;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Calvin</title>
		<link>http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/comment-page-1/#comment-146</link>
		<dc:creator>Calvin</dc:creator>
		<pubDate>Fri, 21 Nov 2008 22:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://keith-hair.com/blog/?p=5#comment-146</guid>
		<description>re: delete doc..*.worm;

So if the worm nodes had another attribute - say type, with &#039;good&#039; or &#039;evil&#039;, and say 2 were &#039;evil&#039; - how would you filter the xml to delete just the evil 2?

You would think:
delete doc..*.worm.(@type==&quot;evil&quot;);
but you get the error &quot;Delete operator is not supported with operand of type XMLList&quot; - strange as you&#039;d assume doc..*.worm is returning an XMLList too...

You can go
doc..*.worm.(@type==&quot;evil&quot;)[0];
which would delete one of them (and naturally [1] to delete the other - but clearly not helpful) - so does that mean looping over the XMLList is the only way to delete multiple nodes based on a filter criteria? Be a bit of a shame if that is the case - hopefully you can tell me I&#039;m missing something obvious??</description>
		<content:encoded><![CDATA[<p>re: delete doc..*.worm;</p>
<p>So if the worm nodes had another attribute &#8211; say type, with &#8216;good&#8217; or &#8216;evil&#8217;, and say 2 were &#8216;evil&#8217; &#8211; how would you filter the xml to delete just the evil 2?</p>
<p>You would think:<br />
delete doc..*.worm.(@type==&#8221;evil&#8221;);<br />
but you get the error &#8220;Delete operator is not supported with operand of type XMLList&#8221; &#8211; strange as you&#8217;d assume doc..*.worm is returning an XMLList too&#8230;</p>
<p>You can go<br />
doc..*.worm.(@type==&#8221;evil&#8221;)[0];<br />
which would delete one of them (and naturally [1] to delete the other &#8211; but clearly not helpful) &#8211; so does that mean looping over the XMLList is the only way to delete multiple nodes based on a filter criteria? Be a bit of a shame if that is the case &#8211; hopefully you can tell me I&#8217;m missing something obvious??</p>
]]></content:encoded>
	</item>
</channel>
</rss>
