ËÑË÷֮· c#´ÓhtmlÖÐÌáÈ¡Îı¾
Ö±½Ó·â×°³ÉÒ»¸öÀàµÄ£¬ÓÃÆðÀ´»¹Í¦·½±ãµÄ
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
/// <summary>
/// HtmlExtract ³éÈ¡htmlÀïÃæµÄÎı¾ÐÅÏ¢
/// </summary>
public class HtmlExtract
{
#region private attributes
private string _strHtml;
#endregion
#region public mehtods
public HtmlExtract(string inStrHtml)
{ _strHtml = inStrHtml;}
public string ExtractText()
{
string result = _strHtml;
result = RemoveComment(result);
result = RemoveScript(result);
result = RemoveStyle(result);
result = RemoveTags(result);
return result.Trim();
}
#endregion
#region private methods
private string RemoveComment(string input)
{
string result = input;
//remove comment
result = Regex.Replace(result, @"<!--[^-]*-->", string.Empty, RegexOptions.IgnoreCase);
return result;
}
Ïà¹ØÎĵµ£º
Æäʵ¾ÍÊÇ´´½¨ÆÕͨÎļþ, CreateFile() ºÍWriteFile. È»ºóÓÃShellExcuteEx()À´´ò¿ª¾ÍÐÐÁË(»á×Ô¶¯µ÷ÓÃIE).
HANDLE handle;
handle=CreateFile(L"\\windows\\google.html",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(INVALID_HANDLE_VALUE!= handle )
{
DWORD Num;
::WriteF ......
ÍøÕ¾ÓÅ»¯
³£ÓõÄHTML±êÇ©:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<body>
<h1>H1±êÇ©£¬¶¨ÒåÎÄÕ±êÌ⣬һ¸öÒ³ÃæÖ»ÒªÒ»¸ö</h1>
<h2>H2±êÇ©£¬¶¨ÒåÎÄÕ±êÌ⣬һ¸öÒ³ÃæÖ»ÒªÒ ......
Ò»ÖÖ£º
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>¼æÈÝFireFoxµÄµ±Ç°Ê±¼äµÄJS½Å±¾</title>
</head>
<body>
<DIV id=time>µ±Ç°Ê±¼ä
<SCRIPT>document.getElementById('time').innerHTML=new Date().toLo ......
ѧÎÞÖ¹¾³£¡£¡£¡
½ñÌìÔÚÂÛ̳»Ø´ðÌû×Ó£¬Ñ§µ½ÁËÒ»ÕУ¬selectÔÀ´¿ÉÒÔʹÓÃoptgroup ±êÇ©£¬¶Ôoption½øÐзÖÀ࣡
ÌØÒâ´ÓÍøÉÏժ¼ÁËÏÂÃæµÄÎÄÕÂ...
ÔÚ htmlÀï,optgroupÕâ¸öÔªËØ¶ÔÓÚÎÒÀ´ËµºÜÉÙÓõ½¡£×î½üÔÚ¹«Ë¾×öÏîĿʱʹÓÃÁËһϣ¬¸Ð¾õ²»´í£¬¿ÉÒÔ¶ÔÊý¾Ý½øÐзÖÀà¡£µ«ÔÚʹÓÃJavaScript Ìí¼Óoptgroupʱ,ÔÚIEÓëFire ......
ÒýÓÃÃüÃû¿Õ¼ä£ºusing System.Xml
1.¼ì²éËùÒª²Ù×÷µÄxmlÎļþÊÇ·ñ´æÔÚ£º
System.IO.File.Exists(Îļþ·¾¶¼°Ãû³Æ);
2.µÃµ½xmlÎļþ£º
£¨1£©ÔÚasp.netÖпÉÒÔÕâÑùµÃµ½:
XmlDocument xmlDoc = new XmlDocument();
//µ¼ÈëxmlÎĵµ
xmlDoc.Load( Server.MapPath("xmlTesting.xml"));
//µ¼Èë×Ö·û´®
/ ......