Re: Selecting immediate children not working properly, even in 3.0.2

10 views
Skip to first unread message

TechnoSophos

unread,
May 24, 2013, 12:08:25 PM5/24/13
to support-...@googlegroups.com
Looks like the bug persists. If you don't mind, can you add the above to issue #112 on GitHub?


There's a little bit of ambiguity in how to process filters for functions like children() and filter(). For example, if children('div>p'), how do we understand the relationship of the combinator? When I tried to solve this last time, I think I might have done it wrong. I need to go back to jQuery and see how it works. Maybe I should just restrict processing to simple selectors instead of allowing combinators.

Thanks for the input!

Matt


On Fri, May 24, 2013 at 10:41 AM, Etienne Noël <etien...@gmail.com> wrote:
Here is an example of my xml code and I'll tell you my problem

<root>
<Document name="A" title="A" >
<Document name="B" title="B" >
<Document name="C" title="C" >
<Section title="1" position="" >
                                 Section ABDFD
  </Section>
                        </Document>
                </Document>
</Document>
</root>

Normally, I have a recursive function but for the sake of simplicity here, I transfered it in two loops imbricated.

when I do this code, I don't want, if I'm in document A, my sections in document C to be listed as children of document A.

foreach (->find('Root')->children('Document') as $element) {

     echo $element->attr('title'); // echoes me A

     foreach($element->children('Section') as $sectionElement) {
       echo $sectionElement->attr('title'); //it is echoing 1, I think since it echoed A before, it shouldn't even get into this loop since A doesn't have any immediate children as Sections
     }
}
 

Am I doing something wrong of is it a bug ?

Thank you

--
You received this message because you are subscribed to the Google Groups "support-querypath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to support-queryp...@googlegroups.com.
To post to this group, send email to support-...@googlegroups.com.
Visit this group at http://groups.google.com/group/support-querypath?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
http://technosophos.com
http://querypath.org
Reply all
Reply to author
Forward
0 new messages