org.jsoup.parser.Parser.xmlParser()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(217)

本文整理了Java中org.jsoup.parser.Parser.xmlParser()方法的一些代码示例,展示了Parser.xmlParser()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.xmlParser()方法的具体详情如下:
包路径:org.jsoup.parser.Parser
类名称:Parser
方法名:xmlParser

Parser.xmlParser介绍

[英]Create a new XML parser. This parser assumes no knowledge of the incoming tags and does not treat it as HTML, rather creates a simple tree directly from the input.
[中]创建一个新的XML解析器。该解析器假定不知道传入的标记,也不将其视为HTML,而是直接从输入创建一个简单的树。

代码示例

代码示例来源:origin: javaee-samples/javaee7-samples

public static String formatHTML(String html) {
  try {
    return parse(html, "", xmlParser()).toString();
  } catch (Exception e) {
    return html;
  }
}

代码示例来源:origin: xtuhcy/gecco

public HtmlParser(String baseUri, String content) {
  long beginTime = System.currentTimeMillis();
  log = LogFactory.getLog(HtmlParser.class);
  this.baseUri = baseUri;
  if (isTable(content)) {
    this.document = Jsoup.parse(content, baseUri, Parser.xmlParser());
  } else {
    this.document = Jsoup.parse(content, baseUri);
  }
  long endTime = System.currentTimeMillis();
  if (log.isTraceEnabled()) {
    log.trace("init html parser : " + (endTime - beginTime) + "ms");
  }
}

代码示例来源:origin: org.jsoup/jsoup

void insert(Token.Comment commentToken) {
  Comment comment = new Comment(commentToken.getData());
  Node insert = comment;
  if (commentToken.bogus) { // xml declarations are emitted as bogus comments (which is right for html, but not xml)
    // so we do a bit of a hack and parse the data as an element to pull the attributes out
    String data = comment.getData();
    if (data.length() > 1 && (data.startsWith("!") || data.startsWith("?"))) {
      Document doc = Jsoup.parse("<" + data.substring(1, data.length() -1) + ">", baseUri, Parser.xmlParser());
      if (doc.childNodeSize() > 0) {
        Element el = doc.child(0);
        insert = new XmlDeclaration(settings.normalizeTag(el.tagName()), data.startsWith("!"));
        insert.attributes().addAll(el.attributes());
      } // else, we couldn't parse it as a decl, so leave as a comment
    }
  }
  insertNode(insert);
}

代码示例来源:origin: deeplearning4j/dl4j-examples

Document document = Jsoup.parse(str, "", Parser.xmlParser());

代码示例来源:origin: org.jsoup/jsoup

req.parser(Parser.xmlParser());

代码示例来源:origin: spring-projects/spring-roo

@Override
public Document parse(String content) {
 Document doc = Jsoup.parse(content, "", Parser.xmlParser());
 doc.outputSettings().prettyPrint(false);
 return doc;
}

代码示例来源:origin: org.glassfish.soteria.test/common

public static String formatHTML(String html) {
  try {
    return parse(html, "", xmlParser()).toString();
  } catch (Exception e) {
    return html;
  }
}

代码示例来源:origin: javaee/security-soteria

public static String formatHTML(String html) {
  try {
    return parse(html, "", xmlParser()).toString();
  } catch (Exception e) {
    return html;
  }
}

代码示例来源:origin: USPTO/PatentPublicData

@Override
  public List<String> getParagraphText(String rawText) {
    String textWithPMarks = getSimpleHtml(rawText);
    Document jsoupDoc = Jsoup.parse(textWithPMarks, "", Parser.xmlParser());

    List<String> paragraphs = new ArrayList<String>();
    for (Element element : jsoupDoc.select("p")) {
      paragraphs.add(element.html());
    }

    return paragraphs;
  }
}

代码示例来源:origin: USPTO/PatentPublicData

@Override
  public List<String> getParagraphText(String rawText) {
    String textWithPMarks = getSimpleHtml(rawText);
    Document jsoupDoc = Jsoup.parse(textWithPMarks, "", Parser.xmlParser());

    List<String> paragraphs = new ArrayList<String>();
    for (Element element : jsoupDoc.select("p")) {
      paragraphs.add(element.html());
    }

    return paragraphs;
  }
}

代码示例来源:origin: USPTO/PatentPublicData

@Override
  public List<String> getParagraphText(String rawText) {
    String textWithPMarks = getSimpleHtml(rawText);
    Document jsoupDoc = Jsoup.parse(textWithPMarks, "", Parser.xmlParser());

    List<String> paragraphs = new ArrayList<String>();
    for (Element element : jsoupDoc.select("p")) {
      paragraphs.add(element.html());
    }

    return paragraphs;
  }
}

代码示例来源:origin: com.vaadin/flow-server

private static StringBuilder createHeaderInjectionCall(String content) {
  StringBuilder inlineContent = new StringBuilder();
  Document document = Jsoup.parse(content, "", Parser.xmlParser());
  for (Element element : document.children()) {
    String tagName = element.tagName();
    inlineContent.append("_inlineHeader('");
    inlineContent.append(tagName).append("',");
    inlineContent.append(makeJsString(element.html()));
    inlineContent.append(");\n");
  }
  return inlineContent;
}

代码示例来源:origin: sedmelluq/lavaplayer

private List<YoutubeTrackFormat> loadTrackFormatsFromDash(String dashUrl, HttpInterface httpInterface, String playerScript) throws Exception {
 String resolvedDashUrl = sourceManager.getCipherManager().getValidDashUrl(httpInterface, playerScript, dashUrl);
 try (CloseableHttpResponse response = httpInterface.execute(new HttpGet(resolvedDashUrl))) {
  int statusCode = response.getStatusLine().getStatusCode();
  if (statusCode != 200) {
   throw new IOException("Invalid status code for track info page response: " + statusCode);
  }
  Document document = Jsoup.parse(response.getEntity().getContent(), CHARSET, "", Parser.xmlParser());
  return loadTrackFormatsFromDashDocument(document);
 }
}

代码示例来源:origin: org.springframework.roo/org.springframework.roo.addon.web.mvc.thymeleaf.addon

@Override
public Document parse(String content) {
 Document doc = Jsoup.parse(content, "", Parser.xmlParser());
 doc.outputSettings().prettyPrint(false);
 return doc;
}

代码示例来源:origin: USPTO/PatentPublicData

@Override
public String getPlainText(String rawText, FreetextConfig textConfig) {
  String simpleHtml = getSimpleHtml(rawText);
  Document simpleDoc = Jsoup.parse(simpleHtml, "", Parser.xmlParser());
  HtmlToPlainText htmlConvert = new HtmlToPlainText(textConfig);
  return htmlConvert.getPlainText(simpleDoc);
}

代码示例来源:origin: org.kie.workbench/kie-wb-common-cli-forms-migration

private String readTaskFormName(DataInputAssociation inputAssociation) {
  Optional<FormalExpression> optional = inputAssociation.getAssignment()
      .stream()
      .filter(assignment -> assignment.getFrom() != null && assignment.getFrom() instanceof FormalExpression)
      .map(assignment -> (FormalExpression)assignment.getFrom())
      .findAny();
  if(optional.isPresent()) {
    return Parser.xmlParser().parseInput(optional.get().getBody(), "").toString();
  }
  return "";
}

代码示例来源:origin: crazyhitty/Munch

@Override
protected String doInBackground(String... strings) {
  try {
    Document rssDocument = Jsoup.connect(mUrl).ignoreContentType(true).parser(Parser.xmlParser()).get();
    mItems = rssDocument.select("item");
  } catch (IOException e) {
    e.printStackTrace();
    return "failure";
  }
  return "success";
}

代码示例来源:origin: Cognifide/knotx

private String getFragmentContent(String content, Element scriptContentDocument) {
 Document resultDocument = Jsoup.parse(content, "UTF-8", Parser.xmlParser());
 Element scriptTag = resultDocument.child(0).empty();
 scriptContentDocument.childNodesCopy().forEach(scriptTag::appendChild);
 return resultDocument.html();
}

代码示例来源:origin: com.vaadin/flow-server

private static Element createDependencyElement(BootstrapContext context,
    JsonObject dependencyJson) {
  String type = dependencyJson.getString(Dependency.KEY_TYPE);
  if (Dependency.Type.contains(type)) {
    Dependency.Type dependencyType = Dependency.Type.valueOf(type);
    return createDependencyElement(context.getUriResolver(),
        LoadMode.INLINE, dependencyJson, dependencyType);
  }
  return Jsoup.parse(dependencyJson.getString(Dependency.KEY_CONTENTS),
      "", Parser.xmlParser());
}

代码示例来源:origin: starlightknight/swagger-confluence

private static Document parseXhtml(final String inputXhtml) {
  final Document originalDocument = Jsoup.parse(inputXhtml, "utf-8", Parser.xmlParser());
  originalDocument.outputSettings().prettyPrint(false);
  originalDocument.outputSettings().escapeMode(xhtml);
  originalDocument.outputSettings().charset("UTF-8");
  return originalDocument;
}

相关文章