2011-01-04 11 views
1

HtmlNodeの属性を設定すると、ノードが選択されたHtmlDocumentに表示されるはずですか?Html Agility Pack:HtmlNodeの属性値を設定するとHtmlDocumentに反映されない

htmlDocumentはHtmlDocumentです。だから、単純化されたコードは次のようになります。今

HtmlNode documentNode = htmlDocument.DocumentNode; 
HtmlNodeCollection nodeCollection = documentNode.SelectNodes(someXPath); 
foreach(var node in nodeCollection) 
    if(SomeCondition(node)) 
     node.SetAttributeValue("class","something"); 

、私はノード変更のクラスattribteを参照してください、私はこの変更がHTMLDocumentののHTMLに反映されません。

答えて

1

実際には、今

_html = theHtml; 
_htmlDocument = new HtmlDocument(); 
HtmlDocument.LoadHtml(theHtml)l 
_documentNode = HtmlDocument.DocumentNode; 

。私は、HTMLのプロパティとDocumentPropertyで、MyHtmlPageクラスを使用

:(ProgrammerTooStupidExceptionのケースだったcoourse操作のDocumentNodeはに影響を及ぼしませんでした_html値。

この返信を投稿すると、HAPの名前がクリアされます。

関連する問題