zzzprojects / html-agility-pack

Html Agility Pack (HAP) is a free and open-source HTML parser written in C# to read/write DOM and supports plain XPATH or XSLT. It is a .NET code library that allows you to parse "out of the web" HTML files.
https://html-agility-pack.net
MIT License
2.65k stars 375 forks source link

Is is possible to update just the attribute value but leave the rest html unchanged? #551

Closed pakhmedzianov closed 5 months ago

pakhmedzianov commented 5 months ago

I need to update attribute value but preserve the rest html exactly like it was at the input. I'm configuring my document like:

        var htmlDoc = new HtmlDocument();
        htmlDoc.OptionFixNestedTags = false;
        htmlDoc.OptionCheckSyntax = false;
        htmlDoc.OptionAutoCloseOnEnd = false;

But unfortunately HtmlAgilityPack, automatically modifies html. And I could not find the way to properly disable it. Please help/advise.

JonathanMagnan commented 5 months ago

Hello @pakhmedzianov ,

Unfortunately, HAP output HTML its own way. We cannot simply change only 1 attribute and have the same exact HTML outputted beside this one. This is currently not feasible through HAP.

Best Regards,

Jon

pakhmedzianov commented 5 months ago

Thanks for clarification!