<?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: xml search class</title>
	<atom:link href="http://www.actionscriptclasses.com/2007/xml-search-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.actionscriptclasses.com/2007/xml-search-class/</link>
	<description>Actionscript Class File Repository</description>
	<lastBuildDate>Thu, 17 Dec 2009 21:45:39 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: asd</title>
		<link>http://www.actionscriptclasses.com/2007/xml-search-class/comment-page-1/#comment-120299</link>
		<dc:creator>asd</dc:creator>
		<pubDate>Tue, 23 Jun 2009 10:54:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.actionscriptclasses.com/2007/xml-search-class/#comment-120299</guid>
		<description>/*
XmlSearch v.1.1
Author:Max Garfinkel
Last Revision: 05/07/2007
new methods added
 
Finds and returns attributes and node values from an xml object
 
public function are:
 
matchAttribute(xml:XML, attributeName:String, attributeValue:String):Boolean
returns true if there exists an attribute of attribute name with the value of attribute value in the xml.
 
getAttributes(xml:XML, searchterm:String, attributeName:String, recursive:Boolean):Array
returns array of 0-* elements containing the attributes attributeName, of node searchterm.
If recursive flag is set to false array will be of 0-1 length.
 
getNodeContent(xml:XML, searchterm:String, recursive:Boolean):Array
returns an array of 0-* elements containing the contents of node searchterm.
If recursive flag is set to false the array will be of 0-1 length.
 
getNodeContentXML(xml:XML, searchterm:String, recursive:Boolean):Array
returns an array of 0-* elements containing the contents of node searchterm.
If recursive flag is set to false the array will be of 0-1 length.
The data is returned as xml blocks within the array.
 
*/
 
class com.maxgarfinkel.data.XmlSearch
{
	private var returnData:Array;
 
		public XmlSearch(){}
 
		//checks if nodes attribute matches filter value
		public function matchAttribute(xml:XML, attributeName:String, attributeValue:String):Boolean
		{
			if(xml.attributes[attributeName].toString() == attributeValue)
				return true;
			else
				return false;
		}
 
        public function getAttributes(xml:XML, searchterm:String, attributeName:String, recursive:Boolean):Array
        {
                this.returnData = [];
                this.searchId(xml, searchterm, attributeName, recursive);
                return(returnData);
        }
 
        private function searchId(xml:XML, searchterm:String, attributeName:String, recursive:Boolean):Void
        {
                for(var i:Number = 0; i &lt; xml.childNodes.length; i++)
                {
                        if(xml.childNodes[i].nodeName.toString() == searchterm)
                                this.returnData.push(xml.childNodes[i].attributes[attributeName]);
                        if(recursive == true)
                                this.searchId(xml.childNodes[i], searchterm, attributeName, recursive);
                }
        }
 
        //Returns xml node data as elements in a single array
        public function getNodeContent(xml:XML, searchterm:String, recursive:Boolean):Array
        {
		this.returnData = [];
                this.searchContent(xml, searchterm, recursive);
                return(returnData);
        }
	//Returns xml node data as xml elements in a single array
	public function getNodeContentXML(xml:XML, searchterm:String, recursive:Boolean):Array
        {
		this.returnData = [];
                this.searchContentReturnXml(xml, searchterm, recursive);
                return(returnData);
        }
 
        private function searchContent(xml:XML, searchterm:String, recursive:Boolean):Void
        {
                for(var i:Number = 0; i &lt; xml.childNodes.length; i++)
                {
                        if(xml.childNodes[i].nodeName.toString() == searchterm)
				this.returnData.push(xml.childNodes[i].firstChild.nodeValue);
                        if(recursive == true)
                                this.searchContent(xml.childNodes[i], searchterm, recursive);
                }
        }
 
	private function searchContentReturnXml(xml:XML, searchterm:String, recursive:Boolean):Void
        {
                 for(var i:Number = 0; i &lt; xml.childNodes.length; i++)
                {
                        if(xml.childNodes[i].nodeName.toString() == searchterm)
				this.returnData.push(xml.childNodes[i]);
                        if(recursive == true)
				this.searchContentReturnXml(xml.childNodes[i], searchterm, recursive);
                }
        }
}</description>
		<content:encoded><![CDATA[<p>/*<br />
XmlSearch v.1.1<br />
Author:Max Garfinkel<br />
Last Revision: 05/07/2007<br />
new methods added</p>
<p>Finds and returns attributes and node values from an xml object</p>
<p>public function are:</p>
<p>matchAttribute(xml:XML, attributeName:String, attributeValue:String):Boolean<br />
returns true if there exists an attribute of attribute name with the value of attribute value in the xml.</p>
<p>getAttributes(xml:XML, searchterm:String, attributeName:String, recursive:Boolean):Array<br />
returns array of 0-* elements containing the attributes attributeName, of node searchterm.<br />
If recursive flag is set to false array will be of 0-1 length.</p>
<p>getNodeContent(xml:XML, searchterm:String, recursive:Boolean):Array<br />
returns an array of 0-* elements containing the contents of node searchterm.<br />
If recursive flag is set to false the array will be of 0-1 length.</p>
<p>getNodeContentXML(xml:XML, searchterm:String, recursive:Boolean):Array<br />
returns an array of 0-* elements containing the contents of node searchterm.<br />
If recursive flag is set to false the array will be of 0-1 length.<br />
The data is returned as xml blocks within the array.</p>
<p>*/</p>
<p>class com.maxgarfinkel.data.XmlSearch<br />
{<br />
	private var returnData:Array;</p>
<p>		public XmlSearch(){}</p>
<p>		//checks if nodes attribute matches filter value<br />
		public function matchAttribute(xml:XML, attributeName:String, attributeValue:String):Boolean<br />
		{<br />
			if(xml.attributes[attributeName].toString() == attributeValue)<br />
				return true;<br />
			else<br />
				return false;<br />
		}</p>
<p>        public function getAttributes(xml:XML, searchterm:String, attributeName:String, recursive:Boolean):Array<br />
        {<br />
                this.returnData = [];<br />
                this.searchId(xml, searchterm, attributeName, recursive);<br />
                return(returnData);<br />
        }</p>
<p>        private function searchId(xml:XML, searchterm:String, attributeName:String, recursive:Boolean):Void<br />
        {<br />
                for(var i:Number = 0; i &lt; xml.childNodes.length; i++)<br />
                {<br />
                        if(xml.childNodes[i].nodeName.toString() == searchterm)<br />
                                this.returnData.push(xml.childNodes[i].attributes[attributeName]);<br />
                        if(recursive == true)<br />
                                this.searchId(xml.childNodes[i], searchterm, attributeName, recursive);<br />
                }<br />
        }</p>
<p>        //Returns xml node data as elements in a single array<br />
        public function getNodeContent(xml:XML, searchterm:String, recursive:Boolean):Array<br />
        {<br />
		this.returnData = [];<br />
                this.searchContent(xml, searchterm, recursive);<br />
                return(returnData);<br />
        }<br />
	//Returns xml node data as xml elements in a single array<br />
	public function getNodeContentXML(xml:XML, searchterm:String, recursive:Boolean):Array<br />
        {<br />
		this.returnData = [];<br />
                this.searchContentReturnXml(xml, searchterm, recursive);<br />
                return(returnData);<br />
        }</p>
<p>        private function searchContent(xml:XML, searchterm:String, recursive:Boolean):Void<br />
        {<br />
                for(var i:Number = 0; i &lt; xml.childNodes.length; i++)<br />
                {<br />
                        if(xml.childNodes[i].nodeName.toString() == searchterm)<br />
				this.returnData.push(xml.childNodes[i].firstChild.nodeValue);<br />
                        if(recursive == true)<br />
                                this.searchContent(xml.childNodes[i], searchterm, recursive);<br />
                }<br />
        }</p>
<p>	private function searchContentReturnXml(xml:XML, searchterm:String, recursive:Boolean):Void<br />
        {<br />
                 for(var i:Number = 0; i &lt; xml.childNodes.length; i++)<br />
                {<br />
                        if(xml.childNodes[i].nodeName.toString() == searchterm)<br />
				this.returnData.push(xml.childNodes[i]);<br />
                        if(recursive == true)<br />
				this.searchContentReturnXml(xml.childNodes[i], searchterm, recursive);<br />
                }<br />
        }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Wagstaff</title>
		<link>http://www.actionscriptclasses.com/2007/xml-search-class/comment-page-1/#comment-116001</link>
		<dc:creator>James Wagstaff</dc:creator>
		<pubDate>Fri, 29 May 2009 17:54:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.actionscriptclasses.com/2007/xml-search-class/#comment-116001</guid>
		<description>Shame the download link is broken.  This looks really handy.</description>
		<content:encoded><![CDATA[<p>Shame the download link is broken.  This looks really handy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeanmichel</title>
		<link>http://www.actionscriptclasses.com/2007/xml-search-class/comment-page-1/#comment-4916</link>
		<dc:creator>jeanmichel</dc:creator>
		<pubDate>Thu, 28 Jun 2007 21:59:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.actionscriptclasses.com/2007/xml-search-class/#comment-4916</guid>
		<description>Hi there, thanks for your little class, i&#039;m sure i&#039;ll use it very often.

The only thing is that i want to make sure i use it the right way, since i dont have extensive experience using flash and actionscript. I&#039;m more used to php.

So here&#039;s my code (doesnt work actually). If you could guide me with tips i sure would be very grateful.

So beforehand, i&#039;ve created the path &quot;classLib/com/maxgarfinkel/data&quot; and have stored your XmlSearch.as file there.

After that, i&#039;ve set the right classpath in flash in order to be able to have access to it.

Should i use #include instead of import?


import com.maxgarfinkel.data.XmlSearch;

xmlData = new XmlSearch();

xDoc = new XML();
xDoc.ignoreWhite = true;
xDoc.load(&quot;test.xml&quot;);

xSearch = new Array;

xSearch = xmlData.getAttributes(&quot;test.xml&quot;, &quot;season2&quot;, &quot;path&quot;, recursive);
trace(xSearch);


thank you so much for your time...</description>
		<content:encoded><![CDATA[<p>Hi there, thanks for your little class, i&#8217;m sure i&#8217;ll use it very often.</p>
<p>The only thing is that i want to make sure i use it the right way, since i dont have extensive experience using flash and actionscript. I&#8217;m more used to php.</p>
<p>So here&#8217;s my code (doesnt work actually). If you could guide me with tips i sure would be very grateful.</p>
<p>So beforehand, i&#8217;ve created the path &#8220;classLib/com/maxgarfinkel/data&#8221; and have stored your XmlSearch.as file there.</p>
<p>After that, i&#8217;ve set the right classpath in flash in order to be able to have access to it.</p>
<p>Should i use #include instead of import?</p>
<p>import com.maxgarfinkel.data.XmlSearch;</p>
<p>xmlData = new XmlSearch();</p>
<p>xDoc = new XML();<br />
xDoc.ignoreWhite = true;<br />
xDoc.load(&#8221;test.xml&#8221;);</p>
<p>xSearch = new Array;</p>
<p>xSearch = xmlData.getAttributes(&#8221;test.xml&#8221;, &#8220;season2&#8243;, &#8220;path&#8221;, recursive);<br />
trace(xSearch);</p>
<p>thank you so much for your time&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
