<?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: E4X delete&#8230; not so obvious&#8230; but easy</title>
	<atom:link href="http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 05:48:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<item>
		<title>By: James</title>
		<link>http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/comment-page-1/#comment-1925</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 08 Feb 2012 05:48:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/#comment-1925</guid>
		<description>Thanks!!! didn&#039;t think that way, though the error message did in a way say so...</description>
		<content:encoded><![CDATA[<p>Thanks!!! didn&#8217;t think that way, though the error message did in a way say so&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: creacog</title>
		<link>http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/comment-page-1/#comment-1897</link>
		<dc:creator>creacog</dc:creator>
		<pubDate>Thu, 22 Dec 2011 00:23:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/#comment-1897</guid>
		<description>@dimpiax, thanks for taking an interest, and yeah, sorry that the comment system is not letting xml code through, so I&#039;m not 100% sure what you are saying. Your comment did prompt me to take another look at this though and come up with the following which i think is a more compact alternative to your function.

In my original line, the use of @ is quite intolerant if presented a node without the named attribute. The &#039;attribute&#039; keyword is far more tolerant. so...

To delete any/all nodes from theXMLObject which match the expression (in this case nodes with attribute &#039;test&#039; of value &#039;marker&#039;) :

&lt;code&gt;var xlist:XMLList = theXMLObject..*.(attribute(&quot;test&quot;)==&quot;marker&quot;);
for( var i:int = xlist.length(); i &gt; 0 ; i-- ) delete xlist[ 0 ];&lt;/code&gt;

Since the xlist:XMLList references the original theXMLObject instance, we are actually deleting nodes from theXMLObject via xlist.</description>
		<content:encoded><![CDATA[<p>@dimpiax, thanks for taking an interest, and yeah, sorry that the comment system is not letting xml code through, so I&#8217;m not 100% sure what you are saying. Your comment did prompt me to take another look at this though and come up with the following which i think is a more compact alternative to your function.</p>
<p>In my original line, the use of @ is quite intolerant if presented a node without the named attribute. The &#8216;attribute&#8217; keyword is far more tolerant. so&#8230;</p>
<p>To delete any/all nodes from theXMLObject which match the expression (in this case nodes with attribute &#8216;test&#8217; of value &#8216;marker&#8217;) :</p>
<p><code>var xlist:XMLList = theXMLObject..*.(attribute("test")=="marker");<br />
for( var i:int = xlist.length(); i > 0 ; i-- ) delete xlist[ 0 ];</code></p>
<p>Since the xlist:XMLList references the original theXMLObject instance, we are actually deleting nodes from theXMLObject via xlist.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dimpiax</title>
		<link>http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/comment-page-1/#comment-1896</link>
		<dc:creator>dimpiax</dc:creator>
		<pubDate>Wed, 21 Dec 2011 16:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/#comment-1896</guid>
		<description>dude, i can write any text with tags. =/</description>
		<content:encoded><![CDATA[<p>dude, i can write any text with tags. =/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dimpiax</title>
		<link>http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/comment-page-1/#comment-1893</link>
		<dc:creator>dimpiax</dc:creator>
		<pubDate>Wed, 21 Dec 2011 16:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/#comment-1893</guid>
		<description>not so good, i.e you have next xml:
var xml : XML = 
    
    
    
    


[code]
function deleteNodesWithAttribute(child : XMLList, attr : String, exist : Boolean = true) : void {
    var list : XMLList;
    if(exist) list = child.(attribute(attr).length());
    else list = child.(attribute(attr).length()==0);
    
    var index : uint = list.length();
    while(index--) delete list[0];
}
[/code]

deleteNodesWithAttribute(xml.items, &quot;country&quot;);
In result: it&#039;ll delete all with attribute &quot;country&quot;.</description>
		<content:encoded><![CDATA[<p>not so good, i.e you have next xml:<br />
var xml : XML = </p>
<p>[code]<br />
function deleteNodesWithAttribute(child : XMLList, attr : String, exist : Boolean = true) : void {<br />
    var list : XMLList;<br />
    if(exist) list = child.(attribute(attr).length());<br />
    else list = child.(attribute(attr).length()==0);</p>
<p>    var index : uint = list.length();<br />
    while(index--) delete list[0];<br />
}<br />
[/code]</p>
<p>deleteNodesWithAttribute(xml.items, &#8220;country&#8221;);<br />
In result: it&#8217;ll delete all with attribute &#8220;country&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeroen Beckers</title>
		<link>http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/comment-page-1/#comment-652</link>
		<dc:creator>Jeroen Beckers</dc:creator>
		<pubDate>Sat, 17 Jan 2009 12:39:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/#comment-652</guid>
		<description>Thanks! :)</description>
		<content:encoded><![CDATA[<p>Thanks! <img src='http://blog.creacog.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jazza</title>
		<link>http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/comment-page-1/#comment-491</link>
		<dc:creator>Jazza</dc:creator>
		<pubDate>Thu, 26 Jun 2008 02:02:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.creacog.co.uk/2008/03/31/e4x-delete-not-so-obvious-but-easy/#comment-491</guid>
		<description>THANK YOU!!!
Deleting nodes by index was starting to drive me craaazzyy so thanks alot (=</description>
		<content:encoded><![CDATA[<p>THANK YOU!!!<br />
Deleting nodes by index was starting to drive me craaazzyy so thanks alot (=</p>
]]></content:encoded>
	</item>
</channel>
</rss>

