- 授权协议: BSD
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: http://informatica.info/projects/html4j/index.html
- 软件文档: http://informatica.info/projects/html4j/doc/api/
软件介绍
HTML4J 是一个 Java 解析 HTML 的类库。示例代码:
Reader re = ...
// Create the document
HTMLDoc doc = new HTMLDoc();
// Load its content
doc.load(re);
// Get the HTML
HTMLFragment html = doc.getHTML();
// Create a 'date' meta-tag
HTMLTag tag = HTMLTag.parse("<meta name=\"date\" content=21/01/2001>");
// Insert it just before the title
html.insertBefore(html.findTagByName("title"), tag);
// Create a paragraph
tag = HTMLTag.create("p");
// Insert '<p>Paragraph</p>' just before a tag with id="someid"
html.insertBefore(html.getIdFinder("someid").getTag().getPosition(),
tag.toString("Paragraph"));
// Create an anchor to foo.html
HTMLTag anchor = HTMLTag.parse("<a href=\"foo.html\">");
// We could also do a 'HTMLTag.create("a")' and then set the 'href'
// attribute using getAttributes().setAttribute("href", "foo.html")
//
// Now we get a tag block with id="otherid"
tag = html.getIdFinder("otherid").getTagBlock();
// Replace the tag that has id="otherid" by the same tag
// embraced by the foo.html anchor
html.replace(tag.getBlockPosition(), anchor.toString(tag));
// For example, if the 'otherid' tag was 'img src="something.jpg"',
// then the result would be:
// '<a target="_blank" rel="nofollow" href="foo.html"><img id="otherid" src="something.jpg"></a>'
//
tag = html.getTagByName("meta");
// We just got the first 'meta' tag found in the document, and now we
// set its name attribute to 'last_update', and its value
// (the 'content' attribute) to "20/01/2001"
tag.getAttributes().setAttribute("name", "last_update");
tag.getAttributes().setAttribute("content", "20/01/2001");
// Commit the changes to the 'meta' tag to the document
html.update(tag);
UNIX环境高级编程(第3版)
史蒂文斯 (W.Richard Stevens)、拉戈 (Stephen A.Rago) / 戚正伟、张亚英、尤晋元 / 人民邮电出版社 / 2014-6-1 / 128.00元
《UNIX环境高级编程(第3版)》是被誉为UNIX编程“圣经”的Advanced Programming in the UNIX Environment一书的第3版。在本书第2版出版后的8年中,UNIX行业发生了巨大的变化,特别是影响UNIX编程接口的有关标准变化很大。本书在保持前一版风格的基础上,根据最新的标准对内容进行了修订和增补,反映了最新的技术发展。书中除了介绍UNIX文件和目录、标准I/......一起来看看 《UNIX环境高级编程(第3版)》 这本书的介绍吧!
