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?
new HtmlNode(...) and append it? Not sure it will work, but worth a shot.
- Oded
But the InnerText property has no setter so I can't set the content.
- Echilon
1 Answers
2
votes
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
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
new HtmlNode(...)and append it? Not sure it will work, but worth a shot. - OdedInnerTextproperty has no setter so I can't set the content. - Echilon