Hi, Thanks for your help.
Now I get a better picture.
Taking your suggestion, I tried this:
//------------------------------------------------------------------------------
// My Class
//------------------------------------------------------------------------------
import mx.xpath.XPathAPI;
class FlashCoders {
private var someXML:XML;
public function FlashCoders(path:String) {
someXML = new XML();
someXML.load(path);
}
public function getSomeValue(someXML){
var nodes:Array = XPathAPI.selectNodeList(someXML,
"/FlashBlog/PostMain/Post/*");
trace(nodes[0]);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
actionscript
//------------------------------------------------------------------------------
var a:FlashCoders = new FlashCoders("main.xml");
a.getSomeValue();
//------------------------------------------------------------------------------
The trace is coming as UnDefined.
I am sure I am doing something wrong here as I am new to writing classes.
On 12/2/05, Pete Hotchkiss <[EMAIL PROTECTED]> wrote:
> Something like
>
> import com.xfactorstudio.xml.xpath.*;
>
> class FlashCoders
> {
>
> private var someXML:XML;
>
> public function FlashCoders(path:String)
> {
> someXML = new XML();
> someXML.load(path);
> }
>
> public getSomeValue():String
> {
> var nodes:Array = XPath.selectNodes(someXML,
> "/some/xpath/String");
>
> return nodes[0].attributes["someAttribt")
> }
> }
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Sajid
> Saiyed
> Sent: 02 December 2005 13:58
> To: [email protected]
> Subject: [Flashcoders] How to use XPATH in a Class?
>
>
> Hi,
> I am trying to create a Class which will take a XML file path as input
> and then using XPath, return required results.
>
> Does anyone know any documentation of example where I can see how this
> can be achieved?
>
> thanks
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders