I guess I'm not quit following.
As you iterate over the returned List, what does it contain? <node> or <childNodeA>? If it contains <node> that node will still have the <childNodeA> in the document, of course, and as a child. I'd argue that "/root/node/childNodeA/.." will return the <nodes> you want. > It always seems that the last part of the query starts the resulting > element Yes, exactly. That's how xpath works. Step-wise. If you want the parent of the <childNodeA> then add another step, considint of two dots ".." that steps back up to the parents of the selected <childNodeA>. So, exactly this: /root/node/childNodeA/.. -bob On Thu, 10 Oct 2002 [EMAIL PROTECTED] wrote: > Actually, > > the @attrib would be unique to each <node> > > <root> > <node attrib="a"> > <childNodeA>text</childNode> > <childNodeB>text</childNode> > <childNodeC>text</childNode> > </node> > <node attrib="b"> > <childNodeA>text</childNode> > <childNodeB>text</childNode> > <childNodeC>text</childNode> > </node> > ..... > ..... > ..... > </root> > > So in turn I want all <childNodeA> in <node> in the entire document. > > /root/node/childNodeA or //childNodeA > > result is : > <childNodeA>text</childNode> > <childNodeA>text</childNode> > ..... > ..... > > But I need <node> to be returned also. > the results should resemble this : > > <node attrib="a"> > <childNodeA>text</childNode> > </node> > <node attrib="b"> > <childNodeA>text</childNode> > </node> > ..... > ..... > ..... > > It always seems that the last part of the query starts the resulting > element > > ex: /root/node/nextnode > result <nextnode>.... > > ex: /root/node[@ID="x"] > result <node ID="x">.... > > ex: /root/node[@ID="x"]/nextnode > result <nextnode>.... > > I want to query something like > > /root/node/nextnode > > and get back > > <node><nextnode>.... > > Now I tried different ways to query, but nothing comes back like > I need it. Is this even possible? > Either I get the parent node but also get all the children too, even > those I have not queried. Or i dont get the parent node at all. > > not sure if this is a part of jaxen or a limitation in xpath. > > thanks again, > alex > > -----Original Message----- > From: bob mcwhirter [mailto:[EMAIL PROTECTED]] > Sent: Thursday, October 10, 2002 1:54 AM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: [Jaxen] Parent node? when searching child elements > > > > I think it might be as simple as: > > /root/node[@attrib='whatever]/childNodeA/.. > > So, that selects the <node>s with the attribute you want, then select's > their <childNodeA>, and then selects those <childNodeA>'s parents, > resulting in a List of <nodes> that match the attribute predicate and > have a <childNodeA> > > Though, the <node> will still have all of its children, include > <childNodeB> and <childNodeC> nodes. > > -bob > > > > On Wed, 9 Oct 2002 [EMAIL PROTECTED] wrote: > > > Good day, > > > > I'm having alittle trouble here. I can only explain this by example. > > So I will try to draw it out as clear as possible. > > > > <root> > > <node attrib=""> > > <childNodeA>text</childNode> > > <childNodeB>text</childNode> > > <childNodeC>text</childNode> > > </node> > > <node attrib=""> > > <childNodeA>text</childNode> > > <childNodeB>text</childNode> > > <childNodeC>text</childNode> > > </node> > > ..... > > ..... > > ..... > > </root> > > > > I would like to search for this query as an example > "/root/nodeA/childNodeA" > > > > Successfully it returns : > > > > <childNodeA>text</childNode> > > <childNodeB>text</childNode> > > ..... > > ..... > > ..... > > > > Now this is all good, but I need to get parent of each childNode to be > > returned > > also so I can use the @attrib found in the parent for later use. > > > > I would a return to looks like this : > > > > <node attrib=""> > > <childNodeA>text</childNode> > > </node> > > <node attrib=""> > > <childNodeB>text</childNode> > > </node> > > ..... > > ..... > > ..... > > > > How would I setup the query to recieve these results. I did trying using > > both parent:: and child::, but I either get the parent node along with the > > rest > > of the child nodes or i end up with the same childNode result without the > > parent. Is there any way to resolve this? > > > > Thank you very much =) > > alex > > > > > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by:ThinkGeek > > Welcome to geek heaven. > > http://thinkgeek.com/sf > > _______________________________________________ > > Jaxen-interest mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/jaxen-interest > > > > -- > Bob McWhirter [EMAIL PROTECTED] > The Werken Company http://werken.com/ > -- Bob McWhirter [EMAIL PROTECTED] The Werken Company http://werken.com/ ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest