完善自己的html parse
说来惭愧,我发现自己写的那个html parse过于理想化,解析xml还差不多,想解析现今的html,估计是不大可能的,所以我把代码重写了一遍,数据结构改成双向链表,这样解析速度更快,最大程度地对html进行容错处理,试验时发现的确可以解析普通html字符串,不需要再严格符合那个xhtml标准了。而且在链式调用的传递参数上不需要再传入dom类型的参数,这样写起来就更加简便了。
好了,废话不多说,看代码:
#include<iostream>
using namespace std;
class node;
class dom;
class nodecollect{
private:
node *n;
int length;
public:
nodecollect();
~nodecollect();
int getlength();
void add(node *nn);
node* item(int i);
};
class node{
private:
int start;
int len;
char name[20];
public:
char* nodehtml();
char* innerhtml();
char* outerhtml();
char* innertext();
char* getattr(char* str);
char* tagname();
void setname(char *str);
node* getparent();
nodecollect* getchild();
node* getnext();
node* getprevious();
node *next;
node *previous;
void setstart(int i);
void setlen(int i);
int getstart();
int getlen();
dom *d;
};
class dom{
private:
char *text;
node *start;
node *end;
int count;
int parse(char *s);
public:
~dom();
char *gettext();
void load(char *str);
node* getitem(int i);
int getcount();
node *getbyid(char* id);
nodecollect* getbytagname(char *tagname);
};
void dom::load(char* str){
start=0;
end=0;
count=0;
int l=strlen(str);
text=new char[l+1];
strcpy(text,str);
char *t=text;
parse(t);
}
int dom::getcount(){
return count;
}
char *dom::gettext(){
return text;
}
node* dom::getitem(int i){
node* n1=start;
while(i--){
&
相关文档:
例如从1.html跳转到2.html:
在1.html中:
<form name="loginForm" action="2.htm?pageid=1&str='s'" method="post">
当页面提交跳转到2.html中:
<script type="text/javascript">
<!--
var str = location.search;
//-->
&l ......
前台 <form id="form1" runat="server" enctype="multipart/form-data">
<input type="flie" id="xxx">
</form>
后台通过 HttpPostedFile f = Request.Files["xxx"]
接收就可以了 ......
//截取部分内容方法
public static string strvalue(string value, int length)
{
string strValue = NoHTML(value);// 去除HTML标记
&nb ......
转载:http://jiangzhengjun.javaeye.com/blog/480996
事件
DOM同时支持两种事件模式:捕获型事件和冒泡型事件,但是,捕获型事件先发生。两种事件流会触及DOM中的所有对象,从document对象开
始,也在document对象结束(大部分兼容标准的浏览会继续将事件捕获/冒泡延续至window对象),DOM中的元素都会连续收到两次事 ......
最近在使用ext嵌入html页面的过程中,遇到一个问题。我们页面都是用html制作的,用iframe的方式嵌入到ext的panel里。其中有一个页面是在按钮触发的时候加载进去的,但是重新刷新浏览器,页面仍然嵌入在panel中,并没有卸载掉,在页面上设置清空缓存也没有效果。
后来我发现,只有在浏览器地址里 ......