Re: [Flashcoders] XPathAPI problems with wildcard searches
I suspect you're expecting similar results to using XSLT where you statement bearing in mind this only works when you use the , which crawls the tree applying the xpath statements. Remember all you statements are relative to the root node that you pass in (in your example is "") To my knowledge the XPathAPI wont support what you want, you're need to do some kind of recursion May be worth looking at the other XPath library, cant remember where it is, but a quick google will point you in the right direction i'm sure... On 8/1/06, Lori Hutchek <[EMAIL PROTECTED]> wrote: The reason I am trying to do the wildcard search is because I have nodes of the same name at different levels and I need them all. So giving a specific path wouldn't give me all of the nodes I need. Here's an expert... Yes * and / are mathematical operators but in the context of a xpath search they are used as you expect if you were doing a regex search... which also supports the * and / What I am attempting to do is get all the node nodes by doing r = XPathAPI.selectNodeList(myXML,"/*/node"); If anyone else has experienced the same trouble and know a way around it or know what I'm doing wrong that would be great! Thanks! Lori- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ryanm Sent: Tuesday, August 01, 2006 2:42 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] XPathAPI problems with wildcard searches > r = XPathAPI.selectNodeList(x,"/*/item"); > The problem is that / and * are both node operators and math operators, so your statement is ambiguous. The obvious answer, based on your example XML, is to use "./items/item", but I don't know if your real XML is more complex or not. If it is, you just need to make your select statement more explicit. ryanm ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- [EMAIL PROTECTED] ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] XPathAPI problems with wildcard searches
The reason I am trying to do the wildcard search is because I have nodes of the same name at different levels and I need them all. So giving a specific path wouldn't give me all of the nodes I need. That's not what your select says, the * wildcard only selectes children. /*/item = select all "item" nodes which are one level below the root (grandchildren of the context node). //item = select all "item" nodes on any level of the document (all descendants of the context node). Yes * and / are mathematical operators but in the context of a xpath search they are used as you expect if you were doing a regex search... which also supports the * and / If you read the W3C spec, they specifically mention this ambiguity and the problems that can arise. It is a known issue with wildcards in XPath, and you should not expect it to behave the same way as any particular implementation of RegEx. What I am attempting to do is get all the node nodes by doing r = XPathAPI.selectNodeList(myXML,"/*/node"); What you want is: r = XPathAPI.selectNodeList(myXML,"//node"); ryanm ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] XPathAPI problems with wildcard searches
> x = new XML(" foo='bar'/>"); > > r = XPathAPI.selectNodeList(x,"/*/item"); If I understand correctly, that search would not find anything, because item is not a child of test, but rather of items. If I'm reading your XPath expression correctly, you would find /items/item, but not /test/items/item. Valid alternative expressions would be //item, /test/*/item, /*/*/item. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] XPathAPI problems with wildcard searches
The reason I am trying to do the wildcard search is because I have nodes of the same name at different levels and I need them all. So giving a specific path wouldn't give me all of the nodes I need. Here's an expert... Yes * and / are mathematical operators but in the context of a xpath search they are used as you expect if you were doing a regex search... which also supports the * and / What I am attempting to do is get all the node nodes by doing r = XPathAPI.selectNodeList(myXML,"/*/node"); If anyone else has experienced the same trouble and know a way around it or know what I'm doing wrong that would be great! Thanks! Lori- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ryanm Sent: Tuesday, August 01, 2006 2:42 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] XPathAPI problems with wildcard searches > r = XPathAPI.selectNodeList(x,"/*/item"); > The problem is that / and * are both node operators and math operators, so your statement is ambiguous. The obvious answer, based on your example XML, is to use "./items/item", but I don't know if your real XML is more complex or not. If it is, you just need to make your select statement more explicit. ryanm ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] XPathAPI problems with wildcard searches
r = XPathAPI.selectNodeList(x,"/*/item"); The problem is that / and * are both node operators and math operators, so your statement is ambiguous. The obvious answer, based on your example XML, is to use "./items/item", but I don't know if your real XML is more complex or not. If it is, you just need to make your select statement more explicit. ryanm ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com