text.Replace("被取代'","新字串");
後者字串取代前者

 text = text.Replace("<img", @"<img class=""rwd-img""");

以下是讀取HTML檔案把一些語法用字串取代成想要的語法
1
2
3
4
5
 string text = System.IO.File.ReadAllText(ConfigPath, System.Text.Encoding.Default);
text = text.Replace("</head>", @"<link href=""./iie/css/rwd.css"" rel=""stylesheet"" type=""text/css""></head>");
text = text.Replace("<img", @"<img class=""rwd-img""");
text = text.Replace("<table class=MsoNormalTable", @"<table class=""rwd-table""");
System.IO.File.WriteAllText(ConfigPath, text, System.Text.Encoding.Default);
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()