1

2

3

How can I extract the 3 p " />

1

2

3

How can I extract the 3 p " />

1

2

3

How can I extract the 3 p "/>

goquery get all <p> tags from just one selector

89 views Asked by At

I have the following example

<div class="myClass"> 
    <div> 
        <div> 
            <p>1</p> 
        </div> 
    </div> 
        <p>2</p> 
    <div> 
    </div> 
    <p>3</p> 
</div>

How can I extract the 3 p tags using goquery or CSS selectors (or both) Maybe in this case the selector would be "div.myClass"

2

There are 2 answers

0
HackerFrosch On BEST ANSWER

You can select all child elements of .myClass with a selector like this:

.myClass p {
    /* Selects all p elements that descend from .myClass */
}

A guide about descendant selectors can be found here.

0
何聊生 On

just p {/* Selects all p elements */}