在桌面应用程序中读取和编辑html文件. [英] read and edit html file in desktop application.
问题描述
大家好,
我有多个HTML文件.实际上,这是电子书的制作过程.我想打开应用程序中的所有HTML文件进行处理.因此,在该HTML文件中,我想在满足条件的特定标记中添加一些属性.
我第一次这样做.任何人都可以有任何想法或解决方案吗?
Hi all,
I have multiple HTML files. actually this is eBook production process.i want open that all HTML files in application for process. so in that HTML file i want to add some attributes in specific tags which satisfy conditions.
i am doing this first time. any one can have any idea or solution ?
thanks in advance.
推荐答案
如果HTML文件是格式正确的XML,则最好.在这种情况下,您可以使用.NET中可用的XML解析方法.
这是我对它们的简短概述:
Your best bet if the HTML file is a well-formed XML. In this case, you can use of the the ways of XML parsing available in .NET.
Here is my short overview of them:
- 使用
System.Xml.XmlDocument
类.它实现了DOM接口;如果文档太大,则这种方法最简单,也足够好.
请参见- 使用类
].System.Xml.XmlTextReader
; library/system.xml.xmldocument.aspx"target =" _ blank"title =" New Window> ^ - 使用类
- 使用类
System.Xml.XmlTextReader
;这是最快的读取方法,尤其是您需要跳过一些数据.
请参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [http://msdn.microsoft.com/en-us/library/bb387063.aspx [
- Use
System.Xml.XmlDocument
class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]. - Use the class
System.Xml.XmlTextReader
; this is the fastest way of reading, especially is you need to skip some data.
See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.Xml.Linq.XDocument
; this is the most adequate way similar to that ofXmlDocument
, supporting LINQ to XML Programming.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
不幸的是,情况并非总是如此,因此您可能需要一些HTML解析器来解决此问题.
试试这个:
http://www.majestic12.co.uk/projects/html_parser.php [ ^ ].
Unfortunately, it is not always the case, so you may need some HTML parser to cope with this problem.
Try this one:
http://www.majestic12.co.uk/projects/html_parser.php[^].
SAKryukov感谢您的答复.
Hi SAKryukov Thanks for reply.
这篇关于在桌面应用程序中读取和编辑html文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!