Edit: I am aware similar questions have been asked but I have not found a resolution to this problem. Maybe I am using the wrong search criteria as this is a new topic for me but I have yet to find something that resolves the problem. Your help (or even a link to a solution) would be greatly appreciated.
I have an HTML file (output from MS Word as Filtered HTML) and I want to get the inner text of the 'MsoTitle' class. From everything I have read, the code should work but I consistently receive a NullReferenceException and am not sure why.
HTML Snippet:
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 15 (filtered)">
</head>
<body lang=EN-US link="#0563C1" vlink="#954F72">
<div class=WordSection1>
<p class=MsoNormal align=center style='text-align:center'><img width=435
height=102 id="Picture 2" src="FUND00_files/image001.png"></p>
<p class=MsoTitle>My Title</p>
...
My code:
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml("C:\\Temp\\Output\\FUND00.htm");
string text = doc.DocumentNode.SelectSingleNode("//p[@class='MsoSubtitle']").InnerText;
Looking at some suggestions here, I tried placing the @ symbol before the quotes but that did not anything to remedy the situation.
Is there something I am doing wrong to get the innertext of this HTML class?