How get a custom tag with html agility pack?

霸气de小男生 提交于 2019-12-12 12:18:33

问题


Need to create a summary/indice

For this I have tags <Document-Title> My Title </Document-Title>

How I get these tags using HTML agility pack?

I have tried this:

 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");

But titles is null


回答1:


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.

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



来源:https://stackoverflow.com/questions/28995014/how-get-a-custom-tag-with-html-agility-pack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!