开发者

Alternatives to HtmlAgilityPack? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_运维百科 Closed 11 years ago.

I don't like some of the design decisions made in HtmlAgilityPack:

  • When using SelectNodes, if no nodes are found, it returns null rather than an empty set, so you can't just foreach over it without a null check.
  • When trying to select children with node.SelectNodes it actually searches from the document root unless you use descendant:: which is not obvious nor expected behavior at all, IMO.
  • HtmlDocument.Load doesn't return the root node, which is what you'd want 99% of the time, I think

You might disagree with that of course, but that's not the point. I'm looking for something different. Something that behaves a little more expected, or something that uses jQuery syntax would be even better. Suggestions?


Started project called SharpQuery

Currently supports ID, class, tag, and attribute selectors.

a
a[href]
a[href^=http://stackoverflow.com]
.class
#id

Update: I'm not maintaining this project, sorry. CsQuery has recent updates (as of July 2013), but I don't have any experience using it.


If you're just parsing the html, another option might be SgmlReader. If you're modifying the html, not so much. Don't recall how it behaves with respect to the issues you raised,but it worth checking out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜