org.jaxen.jdom.JDOMXPath Java Examples

The following examples show how to use org.jaxen.jdom.JDOMXPath. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JdomXpathSelector.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
public JdomXpathSelector(String query) {
    super(query);
    try {
        this.xpath = new JDOMXPath(query);
    } catch (JaxenException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example #2
Source File: KbCsvMojo.java    From Asqatasun with GNU Affero General Public License v3.0 5 votes vote down vote up
private List<String> getUrls(String url) throws JDOMException, JaxenException, IOException {
    SAXBuilder builder = new SAXBuilder();
    EntityResolver resolver = new XhtmlEntityResolver();
    builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
    builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
    builder.setEntityResolver(resolver);
    Document document = builder.build(new URL(url));
    XPath xpath = new JDOMXPath("//*[@id='resultat']//*[@href]/@href");
    List<Attribute> results = xpath.selectNodes(document);
    List<String> urls = new ArrayList<String>();
    for (Attribute attr : results) {
        urls.add(attr.getValue());
    }
    return urls;
}