1

I have a stylesheet stored as a string which I'm trying to add to a parsed HtmlDocument using the Html Agility Pack. I can't set the InnerText of a style node because it has no setter. What's the best way of doing this?

Echilon
  • 10,064
  • 33
  • 131
  • 217

1 Answers1

2

Untested, but should give you the idea:

// 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
Oded
  • 489,969
  • 99
  • 883
  • 1,009