htmlcxxHTML和CSS的C++解析器
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();
}
}
评论
htmlcxxHTML和CSS的C++解析器
htmlcxx是一个C++的HTML解析器和CSS1的解析器。TheparsingpoliticsattempttomimicthebehaviorofMozillaFirefox,soyoushou
htmlcxxHTML和CSS的C++解析器
0
jStyleParserJava 的 CSS 解析器
jStyleParser 是一个开源 Java 的 CSS 解析器,可以在 Java 程序中解析 C
jStyleParserJava 的 CSS 解析器
0
jStyleParserJava 的 CSS 解析器
jStyleParser是一个开源Java的CSS解析器,可以在Java程序中解析CSS样式文件。Maven<dependency> <groupId>net.sf.cs
jStyleParserJava 的 CSS 解析器
0
CSSPoolRuby的CSS解析器
CSSPool是一个Ruby用于解析CSS的工具包,示例代码:require'csspool'sac=CSS::SAC::Parser.newdoc=sac.parse(DATA.read)doc.r
CSSPoolRuby的CSS解析器
0