Re: How to select the immediate children of the current element !??

18 views
Skip to first unread message

TechnoSophos

unread,
May 23, 2013, 2:46:06 PM5/23/13
to support-...@googlegroups.com
Give it a filter: ->children('>p')


On Thu, May 23, 2013 at 1:26 PM, محمد فارس <faress...@gmail.com> wrote:
By using ->children() all elements in the subtree will be selected but I want only the immediate children

HTML Code :

<html>
<head>
</head>
<body>
<div id="hello">

<p>Select This</p>
<p>Select This</p>
<p>Select This</p>

<div>
     <p>Don't Select This</p>
</div>

</div>
</html>

--
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

TechnoSophos

unread,
May 23, 2013, 3:07:55 PM5/23/13
to support-...@googlegroups.com
Hmmm. That should definitely not be the case. Does ->find('#hello>p') work?


On Thu, May 23, 2013 at 2:01 PM, محمد فارس <faress...@gmail.com> wrote:
@Matt
Thank You,
But if you means somthing like that htmlqp('hello.html')->find('#hello')->children('>p')->count();
It is still select all paragraphs that not immediately children of #hello

محمد فارس

unread,
May 23, 2013, 3:12:55 PM5/23/13
to support-...@googlegroups.com
@Matt
->find('#hello>p') Yes it is works very fine.
Is there any way to use somthing like that find('#hello')->something('>p')
:(

TechnoSophos

unread,
May 23, 2013, 3:29:37 PM5/23/13
to support-...@googlegroups.com
I just filed issue #112 for this. https://github.com/technosophos/querypath/issues/112

children('p') should have been all you needed. Instead, it is mis-parsing the filter and applying. I think this is a result of a recent change to the filter() function (which children calls)


--
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.
 
 

محمد فارس

unread,
May 23, 2013, 3:35:46 PM5/23/13
to support-...@googlegroups.com
I really appreciate your efforts ..
You and your QueryPath is very awesome :)

Thank you very much sir

TechnoSophos

unread,
May 23, 2013, 10:55:31 PM5/23/13
to support-...@googlegroups.com
I *think* I've managed to fix this. I just released QueryPath 3.0.2, which has this and a few more minor issues fixed.


--
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.
 
 
Reply all
Reply to author
Forward
0 new messages