Skip to content

Html Parser: Invalid css selector syntax exception thrown for css pseudo-classes #1383

@EverybodyKurts

Description

@EverybodyKurts

I'm trying to select the first paragraph in a group of sibling paragraphs. According to the MDN nth-child() entry, I should be able to do this using :nth-child().

However, this results in a syntax error when using HtmlDocument.CssSelect:

> node.CssSelect("p:nth-child(1)");;
System.Exception: Invalid css selector syntax (char ':' at offset 0)
   at FSharp.Data.HtmlCssSelectors.tokenize'@104(CssSelectorTokenizer this, FSharpList`1 acc, FSharpList`1 sourceChars)
   at FSharp.Data.HtmlCssSelectors.CssSelectorTokenizer.tokenize()
   at FSharp.Data.HtmlCssSelectors.CssSelectorTokenizer.Tokenize(String pCssSelector)
   at FSharp.Data.HtmlNodeModule.Select(IEnumerable`1 nodes, String selector)
   at <StartupCode$FSI_0029>.$FSI_0029.main@()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions