问题
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