Code example for XPathExpression

Methods: evaluate

0
    XPath parser = XPathFactory.newInstance().newXPath();
    String title = "";
    try { 
      XPathExpression titleParser = parser.compile("/api/query/random/page/@title");
      InputSource contenido = new InputSource(new ByteArrayInputStream(s.getBytes(MediaWiki.getCharset())));
      title = titleParser.evaluate(contenido);
    } catch (Exception e) {
      throw new ProcessException("Error parsing the title of the Random Page" + e.toString());
    } 
 
    log.debug("Title: " + title);
    return title;
  } 
 
 
  /** 
   * {@inheritDoc} 
   */ 
  public HttpAction getNextMessage() { 
    return msg;
  }