word转html如何清除冗余代码
我有几万个从word转来的html文件,但这些html文件由doc的100多K变成了几M,几十M。
原来转为html时产生了大量的冗余代码,请问有什么方法可以清除这些垃圾。
需要程序代码。
刚才没分了,现在又有了,可以加分的
/// <summary>
/// 清理Word生成的冗余HTML
/// </summary>
/// <param name="html"> </param>
/// <returns> </returns>
public static string CleanWordHtml(string html)
{
StringCollection sc = new StringCollection();
// get rid of unnecessary tag spans (comments and title)
sc.Add(@" <!--(\w|\W)+?-->");
sc.Add(@" <title>(\w|\W)+? </title>");
// Get rid of classes and styles
sc.Add(@"\s?class=\w+");
sc.Add(@"\s+style='[^']+'");
// Get rid of unnecessary tags
//sc.Add(@"
相关问答:
如题:
可以动态的改变网页的标题吗?
是哪一种网页呢? 如果是html可能比较复杂
可以啊,只要是能执行服务端脚本的。
就是HTML网页
Javascript
嗯,是要用JavaScript,那要怎么实现呢?
<sc ......
用下面这个函数可以读取网页保存下来的HTM文件,但是不能直接读取网页,为什么?
BOOL GetSourceHtml(CString theUrl,CString Filename)
{
CInternetSess ......