Combine CSS-Selector with :not

11 views
Skip to first unread message

KenJ

unread,
Feb 5, 2015, 9:56:23 PM2/5/15
to support-...@googlegroups.com
I'm trying to use CSS Selector to select elements with one class but NOT another:

<div class="info-test">
<h4>Test 1 header</h4>
<p>Test 1 paragraph 1</p>
<p>Test 1 paragraph 2</p>
</div>
<div id="TestThis" class="info-test tab-none">
<div id="Contained">
<h4>ThisThis header 1</h4>
<h4>ThisThis header 2</h4>
<span>ThisThis span<br></span>
</div>
<div class="info-test">
<h4>ThisThat header</h4>
<p>ThisThat paragraph 1</p>
<p>ThisThat paragraph 2</p>
</div>
<div id="ThisThat" class="info-test tab-none">
<div id="Container2">
<h4>ThisHere headaer 1</h4>
<h4>ThisHere headaer 2</h4>
<span>ThisHere span<br></span>
</div>


I'm using this:

htmlqp($html,'body')->branch(".info-test.not:(tab-none) > p");


KenJ

unread,
Feb 5, 2015, 10:00:44 PM2/5/15
to support-...@googlegroups.com
Fixed HTML to allow for p match on both div's.

<div class="info-test">
<h4>Test 1 header</h4>
<p>Test 1 paragraph 1</p>
<p>Test 1 paragraph 2</p>
</div>
<div id="TestThis" class="info-test tab-none">
<div id="Contained">
<h4>ThisThis header 1</h4>
<p>ThisThis header 2</p>

<span>ThisThis span<br></span>
</div>
<div class="info-test">
<h4>ThisThat header</h4>
<p>ThisThat paragraph 1</p>
<p>ThisThat paragraph 2</p>
</div>
<div id="ThisThat" class="info-test tab-none">
<div id="Container2">
<h4>ThisHere headaer 1</h4>
<p>ThisHere headaer 2</p>

<span>ThisHere span<br></span>
</div>

TechnoSophos

unread,
Feb 6, 2015, 12:19:26 PM2/6/15
to support-...@googlegroups.com
I think the syntax is `.info-test:not(.tab-none)`.

If the CSS gets to hairy, you can try using the filter() function(s), too.

--
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.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages