Streaming HTML parser

码农软件 · 软件分类 · HTML解析器 · 2019-04-03 14:29:44

软件介绍

Streaming HTML parser 是一个 C 语言的 HTML 解析器。

示例代码

#include <stdio.h>
#include <streamhtmlparser/htmlparser.h>

int main(void) {
 
unsigned int getchar_ret;
  htmlparser_ctx
*parser = htmlparser_new();

 
while((getchar_ret = getchar()) != EOF) {
   
char c = (char)getchar_ret;

   
/* If we received a '$' character, we output the current tag and attribute
     * name to stdout. */

   
if (c == '$') {
      printf
("[[ ");
     
if (htmlparser_tag(parser))
        printf
("tag=%s ", htmlparser_tag(parser));
     
if (htmlparser_attr(parser))
        printf
("attr=%s ", htmlparser_attr(parser));
      printf
("]]");

   
/* If we read any other character, we pass it to the parser and echo it to
     * stdout. */

   
} else {
      htmlparser_parse_chr
(parser, c);
      putchar
(c);
   
}
 
}
}

输入

<html>   <body $>     <title> $ </title>     <a href="$" alt="$"> url </a>   </body> </html>

输出

<html>   <body [[ tag=body ]]>     <title> [[ tag=title ]] </title>     <a href="[[ tag=a attr=href ]]" alt="[[ tag=a attr=alt ]]"> url </a>   </body> </html>

 

本文地址:https://codercto.com/soft/d/2773.html

程序设计实践

程序设计实践

[美] BRIAN W.KERNIG / 裘宗燕 / 机械工业出版社 / 2007-1 / 59.00元

从排错、测试、性能、可移植性、设计、界面、风格和记法等方面,讨论了程序设计中实际的、又是非常深刻和具有广泛意义的思想、技术和方法,它的翻译出版将填补国内目前这方面书籍的空白。《程序设计实践》(双语版)值得每个梦想并努力使自己成为优秀程序员的人参考,值得每个计算机专业的学生和计算机工作者阅读,也可作为程序设计高级课程的教材或参考书。一起来看看 《程序设计实践》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具