Esempio n. 1
0
  public static String getTextContent(String content, String xPath)
      throws IOException, XPathExpressionException, ParserConfigurationException {
    Assert.isValidString(content);
    Assert.isValidString(xPath);

    final List<String> contents = DomTools.getAsTexts(content, xPath);

    final StringBuilder result = new StringBuilder();

    for (final String current : contents) {
      result.append(current);
    }

    return result.toString();
  }
Esempio n. 2
0
  public static List<String> getAttributes(String content, String xPath)
      throws IOException, XPathExpressionException, ParserConfigurationException {
    Assert.isValidString(content);
    Assert.isValidString(xPath);

    final NodeList nodes = DomTools.getAsNodes(content, xPath);

    final List<String> result = newArrayList();

    for (int index = 0; index < nodes.getLength(); ++index) {
      final Node current = nodes.item(index);
      final String recipeUrl = current.getNodeValue();

      result.add(recipeUrl);
    }

    return result;
  }