Smile
Smile

Reputation: 39

HTML Agility and Powershell (chech contains xPath)

I try to check containing "span iteamprop" in div with class = f6 color-text-secondary mt-2 using the following command, but it doesn't work:

$paragraphs = $doc.DocumentNode.SelectNodes("//div[@class='f6 color-text-secondary mt-2' and contains(//span[@itemprop])")[$i].Select()
    if ($paragraphs) {
        $language = $doc.SelectNodes("//span[@class='d-inline-block ml-0 mr-3']//span[@itemprop]")[$i].InnerText
    }else{
        $language = $null
    }

ghfghfgh

Upvotes: 0

Views: 216

Answers (1)

Prophet
Prophet

Reputation: 33371

Looks like you are missing the closing ] of the element node and it should not be contains since child element is not an attribute of the parent element. Also it should be a dot . there.
Instead

"//div[@class='f6 color-text-secondary mt-2' and contains(//span[@itemprop])"

Try

"//div[@class='f6 color-text-secondary mt-2' and (.//span[@itemprop])]"

Upvotes: 1

Related Questions