-
-
Notifications
You must be signed in to change notification settings - Fork 380
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
Inconsistency between node.OuterHtml
, node.EndNode.OuterHtml
, and node.Closed
#553
Comments
Hello @rvishruth , 1. Is it possible to disable this auto-closing behavior?No, it's currently not possible. However, it look to be easily possible by adding 2 simple options:
The We can surely add those options, but then you will have some side impact as some of your tag is not closed. So you will probably not get the desired behavior even with those options. 2. If not, how can one detect if any changes were made to the original HTML?Besides comparing the HTML, I don't think there is anyway. 3. Why are there no ParseErrors being logged?Not all parsing errors is logged. Implicit ending like Let me know if that answer correctly to your question. Best Regards, Jon |
Hi @JonathanMagnan! Thank you for your response! (2) and (3) makes sense to me! Regarding (1), could you expand on what you mean by
Is this not a bug (because the Endnode is <> even though the there was a closing tag added)? |
Hello @rvishruth ,
Indeed, it can be seen as a bug. I would have expected a null value for the But we didn't think about it years ago when we added the Best Regards, Jon |
I understand, thanks @JonathanMagnan! Few more follow up questions:
This makes sense for the p tag case, where there was no closing tag added. But for the strong tag case, HAP adds a closing tag, so, I'm not sure if a future change will make it so that the
|
Hello @rvishruth , Just to let you know, I'm not the original creator of this library (we purchased it as it was no longer maintained), so what I'm saying is what I understand. The Unlike a So HAP automatically added the end tag when writing the HTML, but when he parsed the HTML, there was indeed no end tag, so no I'm not really sure what the best way to achieve your actual behavior would be. HAP is not 100% HTML compatible so you will surely get some weird behavior especially with invalid HTML. |
Thank you for the explanation @JonathanMagnan! I Given the current functionality, I think checking if EndNode is <> might be the best way to detect if there was a closing tag missing (apart from comparing with the original HTML). I leave it up to you if you want to keep the issue open. I do think the current behavior is inconsistent, but its also unclear if its a bug. |
1. Description
Inconsistency between
node.OuterHtml
,node.EndNode.OuterHtml
, andnode.Closed
HtmlAgilityPack automatically closes certain nodes. However, when it does, the
EndNode
does not get updated accordingly.Related follow-up questions:
2. Exception
N/A
3. Fiddle or Project
https://dotnetfiddle.net/wDNJfT
From output,
p, <p>Hello, , <>, True
- Endnode is<>
and the<p>
tag is not closedstrong, <strong>world!</strong>, <>, True
- EndNode is<>
even though the OuterHTML has a closing tagThe text was updated successfully, but these errors were encountered: