在 Visual C 中使用 HTML Tidy 2010 Windows 窗体项目
我正在使用 VC++ 2010 Express,并尝试包含 HTML Tidy 来对 HTML 代码字符串执行清理。我想要做的是将 HTML 作为字符串(而不是文件)进行处理,并将处理后的清理后的 HTML 保存到字符串(而不是文件)中。该项目是一个C++ Windows窗体项目,编译器是/CLR。
我尝试过以各种方式将 Tidy 附加到我的项目中,次数多得我不愿意承认。我的每一次尝试都失败了,我只是不知道从这里该去哪里。最有前途的是一个名为 TidyManaged 的 .NET 包装器,但我找不到任何文档来解释如何将它与 C++ 一起使用(它似乎适用于 C#)。各种 C++ 包装器根本不适合我。似乎文档非常缺乏关于如何使它们工作的信息。
另外,我准备接受一个根本不使用 tidy 的解决方案,而是使用其他一些等效的 HTML 清理工具。我担心 Tidy 的年龄(2000 年 8 月)以及它对于当今较新的 XHTML 标准是否仍然有效。
另外,如果可能的话,我愿意将 C 库直接合并到我的代码中,而不依赖于 DLL,但我不知道如何使其工作,或者即使它可以工作。
任何有关如何解决此问题的建议将不胜感激,请记住,我们在这里讨论的是 HTML(通常是格式错误的 HTML 和 XHTML)而不是 XML。
提前致谢!
PS - 我是 C++ 新手:/
I am using VC++ 2010 Express and I am attempting to include HTML Tidy to perform cleanup on HTML code strings. What I want to do is process the HTML as a string (NOT from a file) and save the processed cleaned HTML to a string (NOT to a file). The project is a C++ Windows forms project, the compiler is /CLR.
I have attempted, more times than I care to admit, to attach Tidy to my project in various ways. I have failed in every attempt and I'm just not sure where to go from here. The most promising was a .NET wrapper called TidyManaged, but I could not find any documentation to explain how to use it with C++ (it appears to have been meant for C#). The various C++ wrappers are not working for me at all. It seems the documentation is extremely lacking on how to make them work.
Also I am prepared to accept a solution that does not use tidy at all, but some other equivalent HTML cleanup tool. I am concerned about the age of Tidy (August, 2000) and whether it is still effective for today's newer XHTML standards.
Also if it's possible, I am willing to incorporate a C library into my code directly without relying on a DLL, but I have no knowledge on how to make this work or even if it can work.
Any suggestions on how to go about this would be greatly appreciated, keeping in mind that this is HTML we are talking about here (often times malformed HTML and XHTML) and NOT XML.
Thanks in advance!
PS - I am new to C++ :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为这个问题苦苦挣扎了将近48个小时。解决方案找到了!这里是...
使用这里非常简单的 .NET 包装器 http://www. codeproject.com/KB/cs/ZetaHtmlTidy.aspx 将VC项目转换为VC++ 2010 ok并编译为DLL ok。下面是我用来称呼它的代码:
希望这篇文章能让其他人免于经历同样的事情。
编辑:
更进一步,我能够将 VC++ 2008 项目文件从附加到包装器的整洁源代码转换为 VC++ 2010 项目文件。然后,我能够将 tidy 项目(与他的包装类项目分开)编译到 libtidy.lib 静态库(发布和调试)中。然后,我能够将他的包装类合并到我的应用程序中,并指向包含文件和 lib 文件。最终结果正是我想要的,一个将 tidy 合并到我的应用程序中而不需要 dll 依赖项的解决方案。整个经历加快了我将 C 库附加到 C++ 应用程序的学习曲线。
感谢您的建议,我希望有人觉得这篇文章有用。
It's been almost 48 hours struggling with this problem. Solution discovered! Here it is...
Using the very simple .NET wrapper from here http://www.codeproject.com/KB/cs/ZetaHtmlTidy.aspx converted the VC project to VC++ 2010 ok and compiled as a DLL ok. Below is the code I used to call it:
Hopefully this post will spare someone else from going through the same thing.
EDIT:
Taking this a step further I was able to convert the VC++ 2008 project files from the tidy source attached to the wrapper and upgrade them to VC++ 2010 project files. I was then able to compile the tidy project (separate from his wrapper class project) into libtidy.lib static libraries (both release and debug). I was then able to incorporate his wrapper class into my application and point to the include and lib files. The end result was exactly what I wanted, a solution that incorporates tidy into my application without needing to have a dll dependency. This whole experience has accelerated my learning curve for attaching C libraries to my C++ applications.
Thanks for the suggestions, and I hope someone finds this post useful.