易截截图软件、单文件、免安装、纯绿色、仅160KB

完善自己的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--){
&


相关文档:

html 获得浏览器高度

有时页面需要获得用户浏览器的高度才能确定内容显示在哪里,代码
<div style="position:absolute; left:0; top:expression(document.body.clientHeight/2-document.body.clientHeight/4)">
</div>
中,expression(document.body.clientHeight/2)即为获得浏览器高度再除以2 ......

HTML元素map实例

<map name="Map4" id="Map4">
<area shape="rect" mce_shape="rect" coords="659,31,697,45" mce_coords="659,31,697,45" href="product/?keys=289" mce_href="product/?keys=289" />
</map>
<map name=" ......

c++编写html文件解析器

      最近本来是要去那嵌入式课的,但是那课竟然说人数太少,开不了,靠。所以这两天只能自己研究点东西了。记得自己以前就想动手写一个关于dom的解析引擎,只怪自己太懒,一直没动笔。最近在家也没什么事做,就自己动手写一个,花了一天时间写的差不多了,正好锻炼自己的c++水平吧。
 &nb ......

HTML事件


转载:http://jiangzhengjun.javaeye.com/blog/480996
事件
DOM同时支持两种事件模式:捕获型事件和冒泡型事件,但是,捕获型事件先发生。两种事件流会触及DOM中的所有对象,从document对象开
始,也在document对象结束(大部分兼容标准的浏览会继续将事件捕获/冒泡延续至window对象),DOM中的元素都会连续收到两次事 ......

通过HTML 注释性语法判断IE版本

Example:
1.<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
2.<!--[if IE]> 所有的IE可识别 <![endif]-->
3.<!--[if IE 5.0]> 只有IE5.0可以识别 <![endif]-->
4.<!--[if IE 5]> 仅IE5.0与IE5.5可以识别 <![endif]-->
5.<!--[if gt IE 5.0]> IE ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号