-
-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node.OuterHtml Lose img element "/" #425
Comments
Hello @yuejunhi , This is by purpose since closing is invalid in If you wish, we could check if that's possible to add an option to force the "close" which I believe will make sense for many people. Just let us know if you need this option or not. Best Regards, Jon Performance Libraries Runtime Evaluation |
Hello @JonathanMagnan , If you can add an option to force the "close",please like "<img src="123.jpg"/>". Best Regards, yue |
Sure, we will look at it |
Hello @yuejunhi , Look like we already have this options. See the following example: HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.OptionWriteEmptyNodes = true;
htmlDocument.LoadHtml(@"<div><img src=""123.jpg"" />");
var test = htmlDocument.DocumentNode.OuterHtml; Let me know if that's what you were looking for. Best Regards, Jon |
Hello @JonathanMagnan , Could you override the method of “HtmlNode.CreateNode(string html)” ,like "HtmlNode.CreateNode(string html, bool OptionWriteEmptyNodes)”? Best Regards, Yue |
Oh I see, I copied the code from my developer but that doesn't fit 100% for your requirement. Sure, we will look at it. |
Hello @JonathanMagnan , Please see the following example: Yue |
Hello @yuejunhi , The v1.11.31 has been released. It's now possible to pass a builder to choose some options such as Here is an example: HtmlNode node2 = HtmlNode.CreateNode(@"<img src=""123.jpg"" />", options => options.OptionWriteEmptyNodes = true); Let me know if you successfully implemented the solution. Best Regards, Jon |
1. Description
Create img HtmlNode
HtmlNode node = HtmlNode.CreateNode("<img src="123.jpg"/>");
Get the html string from the created node object:node.OuterHtml is equal "<img src="123.jpg">", lose “/”.
How to get complete html string "<img src="123.jpg"/>"?
The text was updated successfully, but these errors were encountered: