List of usage examples for org.jsoup.select Elements outerHtml
public String outerHtml()
From source file:io.sightly.tck.html.HTMLExtractor.java
/** * Checks if the element from the {@code markup} identified by the {@code selector} contains the text from {@code value}. The * {@code url} is used only for caching purposes, to avoid parsing multiple times the markup returned for the same resource. * * @param url the url that identifies the markup * @param markup the markup//from w ww. j av a 2s . c o m * @param selector the selector used for retrieval * @param value the text that should exist in the markup * @return {@code true} if the {@code value} was found in the markup, {@code false} otherwise */ public static boolean contains(String url, String markup, String selector, String value) { ensureMarkup(url, markup); Document document = documents.get(url); Elements elements = document.select(selector); return elements.outerHtml().contains(value); }
From source file:com.cognifide.aet.job.common.datafilters.extractelement.ExtractElementDataModifier.java
private String modifyDataForClassParam(Document document) throws ProcessingException { String result;/* w w w . j a va 2 s . c om*/ Elements elements = document.getElementsByClass(elementClass); if (!elements.isEmpty()) { result = elements.outerHtml(); } else { throw new ProcessingException("No element with class=" + elementClass + " found!"); } return result; }
From source file:mergedoc.core.APIDocument.java
/** * Javadoc ? ??????/*w ww . j a v a2 s . c om*/ * @param className ?? * @param context * @param comment */ private void parseCommonTag(String className, Element element, Comment comment) { Elements dts = element.select("dl dt"); for (Element dt : dts) { String dtText = dt.text(); if (dtText.contains("")) { Elements aTags = dt.nextElementSibling().select("a:has(code)"); for (Element a : aTags) { String url = a.attr("href"); String ref; if (a.childNodeSize() != 1) { ref = aTags.outerHtml(); } else { ref = formatClassName(className, url); ref = FastStringUtils.replace(ref, "%28", "("); ref = FastStringUtils.replace(ref, "%29", ")"); Pattern methodRefPat = PatternCache.getPattern("-(.*)-$"); Matcher methodRefMat = methodRefPat.matcher(ref); if (methodRefMat.find()) { ref = FastStringUtils.replaceAll(ref, "-(.*)-$", "($1)"); // for Java8 ref = FastStringUtils.replace(ref, "-", ","); // for Java8 ref = FastStringUtils.replace(ref, ":A", "[]"); // for Java8 } } comment.addSee(ref); } } else if (dtText.contains("???:")) { comment.addSince(dt.nextElementSibling().text()); } } }
From source file:org.arb.extractor.DomTreeWalker.java
/** * Rewrite the source code with resource extracted. * //from w w w. j a v a 2 s. c o m * @param codeUnit AbstractCodeUnit instance that has all information related to a source file. * @return source code after resource replacement. */ @Override public String rewriteSource(AbstractCodeUnit codeUnit) { // Apply all the replacements ArrayList<CodeReplacement> replacementList = codeUnit.getReplacementList(); for (CodeReplacement replacement : replacementList) { DomCodeReplacement domReplacement = (DomCodeReplacement) replacement; if (domReplacement.isNewId()) { if (domReplacement.shouldUseArbId()) { domReplacement.getElement().attr("arb:id", replacement.getResourceId()); } else { domReplacement.getElement().attr("id", replacement.getResourceId()); } } } // return things back Document doc = codeUnit.getDomDocument(); Elements elements = doc.getElementsByTag("html"); return elements.outerHtml(); }