我有一个存储为字符串的样式表,我试图使用 Html Agility Pack 将其添加到已解析的 HtmlDocument 中。我无法设置 style
节点的 InnerText,因为它没有 setter 。执行此操作的最佳方法是什么?
最佳答案
未经测试,但应该给你想法:
// doc is the HtmlDocument
var style = doc.CreateElement("style");
var text = doc.CreateTextNode("some CSS here");
style.AppendChild(text);
doc.DocumentNode.AppendChild(style); // or, AppendChild to any node
关于c# - 使用 HAP 添加样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14083457/