• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NodeTraversor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jsoup.select.NodeTraversor的典型用法代码示例。如果您正苦于以下问题:Java NodeTraversor类的具体用法?Java NodeTraversor怎么用?Java NodeTraversor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NodeTraversor类属于org.jsoup.select包,在下文中一共展示了NodeTraversor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: deserialize

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
@Override
public _Object deserialize(Reader reader, Config config) {
	StringBuilder sb = new StringBuilder();
	char[] buff = new char[100];
	int len;
	try {
		while ((len = reader.read(buff)) > 0)
			sb.append(buff, 0, len);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}

	Document doc = Jsoup.parse(sb.toString());
	JSoupHtmlNodeVisitor visitor = new JSoupHtmlNodeVisitor();
	NodeTraversor traversor = new NodeTraversor(visitor);
	traversor.traverse(doc);
	return visitor.getObject();
}
 
开发者ID:jackhatedance,项目名称:visual-programming,代码行数:19,代码来源:HtmlSerialzer.java


示例2: getPlainText

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Format an Element to plain-text
 * @param element the root element to format
 * @return formatted text
 */
private static String getPlainText(Element element) {
    FormattingVisitor formatter = new FormattingVisitor();
    NodeTraversor.traverse(formatter, element); // walk the DOM, and call .head() and .tail() for each node

    return formatter.toString();
}
 
开发者ID:3wks,项目名称:generator-thundr-gae-react,代码行数:12,代码来源:HtmlFormattingUtil.java


示例3: cleanDescription

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * removes HTML tags from a google calendar event's description
 * @param description  an event description possibly containing HTML tags
 * @return an event description free of HTML tags
 */
public static String cleanDescription(String description)
{
    FormattingVisitor formatter = new FormattingVisitor();
    new NodeTraversor(formatter).traverse(Jsoup.parse(description));
    return formatter.toString();
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:12,代码来源:HTMLStripper.java


示例4: getPlainText

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Format an Element to plain-text
 * @param element the root element to format
 * @return formatted text
 */
public String getPlainText(Element element) {
	FormattingVisitor formatter = new FormattingVisitor();
	NodeTraversor traversor = new NodeTraversor(formatter);
	traversor.traverse(element); // walk the DOM, and call .head() and .tail() for each node

	return formatter.toString();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:13,代码来源:HtmlToPlainText.java


示例5: convert

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Converts a jsoup document into the provided W3C Document. If required, you can set options on the output document
 * before converting.
 * @param in jsoup doc
 * @param out w3c doc
 * @see org.jsoup.helper.W3CDom#fromJsoup(org.jsoup.nodes.Document)
 */
public void convert(org.jsoup.nodes.Document in, Document out) {
    if (!StringUtil.isBlank(in.location()))
        out.setDocumentURI(in.location());

    org.jsoup.nodes.Element rootEl = in.child(0); // skip the #root node
    NodeTraversor traversor = new NodeTraversor(new W3CBuilder(out));
    traversor.traverse(rootEl);
}
 
开发者ID:cpusoft,项目名称:common,代码行数:16,代码来源:W3CDom.java


示例6: getPlainText

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Format an Element to plain-text
 * @param element the root element to format
 * @return formatted text
 */
public String getPlainText(Element element) {
    FormattingVisitor formatter = new FormattingVisitor();
    NodeTraversor traversor = new NodeTraversor(formatter);
    traversor.traverse(element); // walk the DOM, and call .head() and .tail() for each node

    return formatter.toString();
}
 
开发者ID:cpusoft,项目名称:common,代码行数:13,代码来源:HtmlToPlainText.java


示例7: traverse

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Perform a depth-first traversal through this node and its descendants.
 * @param nodeVisitor the visitor callbacks to perform on each node
 * @return this node, for chaining
 */
public Node traverse(NodeVisitor nodeVisitor) {
    Validate.notNull(nodeVisitor);
    NodeTraversor traversor = new NodeTraversor(nodeVisitor);
    traversor.traverse(this);
    return this;
}
 
开发者ID:cpusoft,项目名称:common,代码行数:12,代码来源:Node.java


示例8: getEmbeddedResourceURLs

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
@Override
public Iterator<URL> getEmbeddedResourceURLs(String userAgent, byte[] html, URL baseUrl,
        URLCollection coll, String encoding) throws HTMLParseException {
    try {
        // TODO Handle conditional comments for IE
        String contents = new String(html,encoding);
        Document doc = Jsoup.parse(contents);
        JMeterNodeVisitor nodeVisitor = new JMeterNodeVisitor(new URLPointer(baseUrl), coll);
        new NodeTraversor(nodeVisitor).traverse(doc);
        return coll.iterator();
    } catch (Exception e) {
        throw new HTMLParseException(e);
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:15,代码来源:JsoupBasedHtmlParser.java


示例9: getPlainText

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Format an Element to plain-text
 *
 * @param element the root element to format
 * @return formatted text
 */
public String getPlainText(Element element) {
    FormattingVisitor formatter = new FormattingVisitor();
    NodeTraversor traversor = new NodeTraversor(formatter);
    traversor.traverse(element); // walk the DOM, and call .head() and .tail() for each node

    return formatter.toString();
}
 
开发者ID:KonradJanica,项目名称:aMatch,代码行数:14,代码来源:QuestionSearch.java


示例10: getLatexText

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Format an Element to LaTeX
 *
 * @param element
 *            the root element to format
 * @return formatted text
 */
public static String getLatexText(Element element) {
	FormattingVisitor formatter = new FormattingVisitor();
	NodeTraversor traversor = new NodeTraversor(formatter);
	traversor.traverse(element); // walk the DOM, and call .head() and
									// .tail() for each node

	return formatter.toString();
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:16,代码来源:Html2LaTeX.java


示例11: convert

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Converts a jsoup document into the provided W3C Document. If required, you can set options on the output document
 * before converting.
 * @param in jsoup doc
 * @param out w3c doc
 * @see org.jsoup.helper.W3CDom#fromJsoup(org.jsoup.nodes.Document)
 */
public void convert(org.jsoup.nodes.Document in, Document out) {
    if (!StringUtil.isBlank(in.location()))
        out.setDocumentURI(in.location());

    org.jsoup.nodes.Element rootEl = in.child(0); // skip the #root node
    NodeTraversor.traverse(new W3CBuilder(out), rootEl);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:15,代码来源:W3CDom.java


示例12: getPlainText

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Format an Element to plain-text
 * @param element the root element to format
 * @return formatted text
 */
public String getPlainText(Element element) {
    FormattingVisitor formatter = new FormattingVisitor();
    NodeTraversor.traverse(formatter, element); // walk the DOM, and call .head() and .tail() for each node

    return formatter.toString();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:12,代码来源:HtmlToPlainText.java


示例13: getEmbeddedResourceURLs

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
@Override
public Iterator<URL> getEmbeddedResourceURLs(byte[] html, URL baseUrl,
        URLCollection coll, String encoding) throws HTMLParseException {
    try {
        String contents = new String(html,encoding); 
        Document doc = Jsoup.parse(contents);
        JMeterNodeVisitor nodeVisitor = new JMeterNodeVisitor(new URLPointer(baseUrl), coll);
        new NodeTraversor(nodeVisitor).traverse(doc);
        return coll.iterator();
    } catch (Exception e) {
        throw new HTMLParseException(e);
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:14,代码来源:JsoupBasedHtmlParser.java


示例14: convertNodeToText

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
protected static String convertNodeToText(Node node) {
	if (node == null)
		return "";
	StringBuilder buffer = new StringBuilder();
	new NodeTraversor(new ToTextNodeVisitor(buffer)).traverse(node);
	return buffer.toString().trim();
}
 
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:8,代码来源:GetSitemapHtmlClient.java


示例15: convertElementsToText

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
protected static String convertElementsToText(Elements elements) {
	if (elements == null || elements.isEmpty())
		return "";
	StringBuilder buffer = new StringBuilder();
	NodeTraversor nt = new NodeTraversor(new ToTextNodeVisitor(buffer));
	for (Element element : elements) {
		nt.traverse(element);
	}
	return buffer.toString().trim();
}
 
开发者ID:searchisko,项目名称:elasticsearch-river-remote,代码行数:11,代码来源:GetSitemapHtmlClient.java


示例16: toPlainText

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
/**
 * Convert an HTML string to a plain-text string.
 *
 * @param htmlStr a string containing HTML markup
 * @return formatted text
 */
public static String toPlainText(String htmlStr) {
  Document doc = Jsoup.parse(htmlStr);
  PlainTextFormattingVisitor formatter = new PlainTextFormattingVisitor();
  NodeTraversor traversor = new NodeTraversor(formatter);
  traversor.traverse(doc); // walk the DOM, and call .head() and .tail() for each node
  return formatter.toString();
}
 
开发者ID:karma-exchange-org,项目名称:karma-exchange,代码行数:14,代码来源:HtmlUtil.java


示例17: copySafeNodes

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
private void copySafeNodes(Element source, Element destination) {
    CleaningVisitor cleaningVisitor = new CleaningVisitor(source, destination);
    NodeTraversor traversor = new NodeTraversor(cleaningVisitor);
    traversor.traverse(source);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:6,代码来源:HeadCleaner.java


示例18: copySafeNodes

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
private int copySafeNodes(Element source, Element dest) {
    CleaningVisitor cleaningVisitor = new CleaningVisitor(source, dest);
    NodeTraversor traversor = new NodeTraversor(cleaningVisitor);
    traversor.traverse(source);
    return cleaningVisitor.numDiscarded;
}
 
开发者ID:cpusoft,项目名称:common,代码行数:7,代码来源:Cleaner.java


示例19: outerHtml

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
protected void outerHtml(Appendable accum) {
    new NodeTraversor(new OuterHtmlVisitor(accum, getOutputSettings())).traverse(this);
}
 
开发者ID:cpusoft,项目名称:common,代码行数:4,代码来源:Node.java


示例20: outerHtml

import org.jsoup.select.NodeTraversor; //导入依赖的package包/类
protected void outerHtml(StringBuilder accum) {
    new NodeTraversor(new OuterHtmlVisitor(accum, getOutputSettings())).traverse(this);
}
 
开发者ID:rogerxaic,项目名称:gestock,代码行数:4,代码来源:Node.java



注:本文中的org.jsoup.select.NodeTraversor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InvalidInputException类代码示例发布时间:2022-05-21
下一篇:
Java ExceptionEvent类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap