当前位置: 首页 > 软件库 > Web应用开发 > HTML解析器 >

htmlcxx

HTML和CSS的C++解析器
授权协议 LGPL
开发语言 C/C++
所属分类 Web应用开发、 HTML解析器
软件类型 开源软件
地区 不详
投 递 者 甘祺
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

htmlcxx 是一个 C++ 的 HTML 解析器和 CSS1 的解析器。The parsing politics attempt to mimic the behavior of Mozilla Firefox, so you should expect parse trees similar to those created by Firefox. However, it does not insert nonexistent stuff in your HTML. Therefore, serializing the DOM tree gives exactly the same output as the original HTML document. Another key feature is an STL-like tree navigation API provided by the tree.hh template library.

示例代码:

#include <htmlcxx/html/ParserDom.h>
...

//Parse some html code
string html = "<html><body>hey</body></html>";
HTML::ParserDom parser;
tree<HTML::Node> dom = parser.parseTree(html);

//Print whole DOM tree
cout << dom << endl;

//Dump all links in the tree
tree<HTML::Node>::iterator it = dom.begin();
tree<HTML::Node>::iterator end = dom.end();
for (; it != end; ++it)
{
if (it->tagName() == "A")
{
it->parseAttributes();
cout << it->attributes("href");
}
}

//Dump all text of the document
it = dom.begin();
end = dom.end();
for (; it != end; ++it)
{
if ((!it->isTag()) && (!it->isComment()))
{
cout << it->text();
}
}
  • 软件简介 htmlcxx 是一个 C++ 的 HTML 解析器和 CSS1 的解析器。The parsing politics attempt to mimic the behavior of Mozilla Firefox, so you should expect parse trees similar to those created by Firefox. However, it does

  • htmlcxx - html and css APIs for C++ Description htmlcxx is a simple non-validating css1 and html parser for C++. Although there are several other html parsers available, htmlcxx has some characteristi

  • #include <string> #include <iostream> #include <sstream> #include <htmlcxx/html/ParserDom.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h>   using namespace std; using namespace htmlcxx;

  • html与xml格式上比较相似,但xml不并一定能支持html的解析。这里介绍一个c++解析html的开源项目: htmlcxx 一、代码示例 1、项目源码下载之后,使用vs打开即可,默认为生成.lib静态库及MTd模式,可以在属性中修改指定为MD/MDd(MTd在实际项目中运用相对比较少,具体得看宿主项目的编译模式为MT还是MD)。 2、HTML::ParserDom 对象可以将 html文本字

 相关资料
  • 简单的例子 这个例子展示了如何从字符串中加载 CSS 样式: #include <LCUI.h> #include <LCUI/gui/css_library.h> #include <LCUI/gui/css_parser.h> ​ int main(void) { LCUI_Selector selector = Selector(".button"); LCUI_Style

  • 模版中默认的 CSS 文件并不依赖 conditional class names,conditional style sheets,或 Modernizr 的表现效果,尽可以放心按自己的偏好放手去干。 Normalize.css 为了确保所有浏览器的渲染效果更加一致且符合标准,我们引入了 Normalize.css——这是一个现代化、紧密结合 HTML 5 的可选方案,可以用来实现浏览器的 CS

  • 问题内容: Update 2018 :这个问题早在PostCSS出现之前就被问到了,我可能会使用它。 我想将一滴CSS解析为AST,以便为某些CSS指令添加前缀。 是否有CSS解析器可用于JavaScript或Node? 我搜索了NPM。我发现的唯一有用的结果是parser-lib,但是它是基于流的,看起来我需要为每个CSS节点编写自己的发射器。 更新: 我也找到了JSCSSP,但是它没有文档…

  • CSS样式 Stylus完全支持常规的CSS样式解析,这意味着你无需寻求其它解析器,或指定特别的文件使用特别的样式。 例子 下面是个使用缩进方法的小样式: border-radius() -webkit-border-radius arguments -moz-border-radius arguments border-radius arguments body a font

  • 本文向大家介绍C++生成和解析XML文件的讲解,包括了C++生成和解析XML文件的讲解的使用技巧和注意事项,需要的朋友参考一下 概述 1.xml 指可扩展标记语言(EXtensible Markup Language) 2.xml 是一种标记语言,类似html 3.xml 的设计宗旨是传输数据,而非显示数据 4.xml 标签没有被预定义。需要自行定义标签 XML与HTML区别 1.xml 不是 h

  • 本文向大家介绍深入解析C++和JAVA的字符串,包括了深入解析C++和JAVA的字符串的使用技巧和注意事项,需要的朋友参考一下 所有的字符串类都起源于C语言的字符串,而C语言字符串则是字符的数组。C语言中是没有字符串的,只有字符数组。 谈一下C++的字符串:C++提供两种字符串的表示:C风格的字符串和标准C++引入的string类型。一般建议用string类型,但是实际情况中还是要使用老式C风格的

  • 问题内容: 我已经完成了有关iOS中JSON的Raywenderlich教程,但是我很难将其调整为适合自己的JSON文件。这是 我的JSON : 这是 我的代码 : 日志返回。 问题答案: 你这样做是不对的。您已正确将JSON数据填充到字典(名为)中。但你有一个(被称为你的主要内部)和价值的是内部数组。 正确的代码是: 了解概念。这取决于你的内心里有什么。如果它是一个数组(在Values内部),则

  • 本文向大家介绍解析在C#中接口和类的异同,包括了解析在C#中接口和类的异同的使用技巧和注意事项,需要的朋友参考一下 不同点: 不能直接实例化接口。 接口不包含方法的实现。 接口可以多继承,类只能单继承。 类定义可以在不同的源文件之间进行拆分。 相同点: 接口、类和结构都可以从多个接口继承。 接口类似于抽象基类:继承接口的任何非抽象类型都必须实现接口的所有成员。 接口和类都可以包含事件、索引器、属性