HAPライブラリを使用してHTMLタグに新しい属性を作成しようとしています。
HtmlDocument doc = new HtmlDocument();
doc.Load(PATH);
HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("//input");
nodes[0].Attributes["foo"].Value = "baa"; /* try add 'foo' attribute with 'baa' value in input HTML element. */
doc.Save(@"C:\foo.html");
ただし、例外が発生します。
Object reference not set to an instance of an object.
これを修正する方法は?