如何使用html敏捷包获取自定义标签? [英] How get a custom tag with html agility pack?

查看:59
本文介绍了如何使用html敏捷包获取自定义标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要创建摘要/索引

为此,我有标签<Document-Title> My Title </Document-Title>

如何使用HTML敏捷包获取这些标签?

How I get these tags using HTML agility pack?

我已经尝试过了:

 HtmlDocument html = new HtmlDocument();
  html.Load(new StringReader(Document.Content)); //Is the <html> I'm load in database

  var titles = html.DocumentNode.SelectNodes("//Document-Title");

但是标题为空

推荐答案

只需使用//document-title,它就必须小写,HAP默认将标签小写,我相信原因是xHTML要求标签名称为小写字母,因此HAP可能认为,但不是特定于标准HTML,它可以很好地使用带有大写字母的标记.

Just use //document-title , it jsut need to be lowercase, HAP lowercases the tags by default, i believe the reason is that xHTML required the tag names to be lower-case, so HAP probably considered that, but its not specific to standard HTML, its fine to use tags with capitalization.

更新:经过一些研究后,小写是对xpath的要求,HAP本身对大小写敏感,并且不关心XHTML.

Update: after some research lower case is an xpath requirement, HAP is case insenstive on its own and does not care about XHTML.

这篇关于如何使用html敏捷包获取自定义标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆