Examples of evaluateXPath()

@param xPathExpression @return @throws XPatherException

Examples of org.htmlcleaner.TagNode.evaluateXPath()

  public static Collection<String> findAllLinkHref(String html, String hostUrl) throws Exception{
    Collection<String> urls = new ArrayList<String>();
   
    HtmlCleaner cleaner = new HtmlCleaner();
    TagNode node = cleaner.clean(html);
    Object[] ns = node.evaluateXPath("//a[@href]");
    for (Object object : ns) {
      TagNode node2=(TagNode) object;
      String href = node2.getAttributeByName("href");
      if (href == null || href.trim().length() == 0)
        continue;
View Full Code Here

Examples of org.htmlcleaner.TagNode.evaluateXPath()

        final List<Field> fields = target.getModel().getField();
    String isModelArray = target.getModel().getIsArray();
    String modelXpath = target.getModel().getXpath();
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    if ("1".equals(isModelArray) || "tre".equals(isModelArray)){
      Object[] nodeVals = rootNode.evaluateXPath(modelXpath);
          if (nodeVals != null && nodeVals.length > 0){
            for (int i = 0; i < nodeVals.length; i++) {
          list.add(parseHtmlMap(nodeVals[i], fields));
            }
          }
View Full Code Here

Examples of org.htmlcleaner.TagNode.evaluateXPath()

        String regex = parser.getRegex();
        String skipRgxFail = parser.getSkipRgxFail();
        try {
          if (xpath != null && xpath.trim().length() > 0) {
            TagNode tag = (TagNode)item;
            Object[] nodeVals = tag.evaluateXPath(xpath);
            if (nodeVals == null || nodeVals.length == 0)
              continue;
           
            if (attribute != null && attribute.trim().length() > 0){
              for (Object nodeVal : nodeVals){
View Full Code Here

Examples of org.htmlcleaner.TagNode.evaluateXPath()

  public static Object evalXpath(String html, String xpath, String attribute){
    List<Object> result = new ArrayList<Object>();
    HtmlCleaner cleaner = new HtmlCleaner();
    try {
      TagNode tagNode = cleaner.clean(html);
      Object[] nodeVals = tagNode.evaluateXPath(xpath);
      for (Object tag : nodeVals){
        TagNode _tag = (TagNode)tag;
        Object val = null;
        if (attribute != null)
          val = _tag.getAttributeByName(attribute);
View Full Code Here

Examples of org.htmlcleaner.TagNode.evaluateXPath()

    Object[] myNodes;
       


        myNodes = node.evaluateXPath( "//div[@id='content']//h1/text( )");

    String[] data = Util.patternExtract( "([^(]+)"+Translator.get(Translator.LEVEL)+" (\\d+)", myNodes[0].toString(), 2);
        String currentLocation = Translator.translate( data[0].trim());
        int    level    = Integer.parseInt( data[1].trim());
    System.out.printf( "currentLocation=%s, level=%d\n\n", currentLocation, level);
View Full Code Here

Examples of org.htmlcleaner.TagNode.evaluateXPath()

        String currentLocation = Translator.translate( data[0].trim());
        int    level    = Integer.parseInt( data[1].trim());
    System.out.printf( "currentLocation=%s, level=%d\n\n", currentLocation, level);

    int  numNode = 0;
        Object[] domTroops = node.evaluateXPath( "//div[@id='content']//table");
        for( Object t : domTroops) {
          if( t instanceof TagNode) {
            TagNode domTroop = (TagNode) t;
           
                Object[] domTroopTypes = domTroop.evaluateXPath( ".//tbody[@class='units']/tr[position()=1]/td/img/@title");
View Full Code Here

Examples of org.htmlcleaner.TagNode.evaluateXPath()

        Object[] domTroops = node.evaluateXPath( "//div[@id='content']//table");
        for( Object t : domTroops) {
          if( t instanceof TagNode) {
            TagNode domTroop = (TagNode) t;
           
                Object[] domTroopTypes = domTroop.evaluateXPath( ".//tbody[@class='units']/tr[position()=1]/td/img/@title");
                Object[] domTroopQuantities = node.evaluateXPath( ".//tbody[@class='units']/tr[position()=2]/td/text()");
                Object[] domLocations = node.evaluateXPath( "//div[@id='content']//table/thead/tr/td[2]/a/@href");

              String codLocation = "<local>";
              if( numNode > 0) { // Other villages
View Full Code Here

Examples of org.htmlcleaner.TagNode.evaluateXPath()

        IOVillage.updateVillageOverview( village);
        System.out.println( village);


    Object[] myNodes;
        myNodes = node.evaluateXPath( "body");
       
    // serialize a node to a file, output stream, DOM, JDom...
    System.out.println( "\n\n\nINICIO");
    PrettyXmlSerializer serializer = new PrettyXmlSerializer( props);
View Full Code Here

Examples of org.htmlcleaner.TagNode.evaluateXPath()

        ArrayList<ArrayList<Object>> constructionQueue = new ArrayList<ArrayList<Object>>( );
         
        for( Object o : artifacts) {
            if( o instanceof TagNode) {
                TagNode n = (TagNode) o;
                String desc = n.evaluateXPath( "td[position()=2]/text()")[0].toString();
                String time = n.evaluateXPath( "td[position()=3]/span/text()")[0].toString();
                String ready = n.evaluateXPath( "td[position()=4]/text()")[0].toString();
//              System.out.printf( "Desc='%s', time='%s', ready='%s'\n", desc, time, ready);
               
                String[] data = Util.patternExtract( "([^(]+)\\("+Translator.get(Translator.LEVEL)+" (\\d+)\\)", desc, 2);
View Full Code Here

Examples of org.htmlcleaner.TagNode.evaluateXPath()

         
        for( Object o : artifacts) {
            if( o instanceof TagNode) {
                TagNode n = (TagNode) o;
                String desc = n.evaluateXPath( "td[position()=2]/text()")[0].toString();
                String time = n.evaluateXPath( "td[position()=3]/span/text()")[0].toString();
                String ready = n.evaluateXPath( "td[position()=4]/text()")[0].toString();
//              System.out.printf( "Desc='%s', time='%s', ready='%s'\n", desc, time, ready);
               
                String[] data = Util.patternExtract( "([^(]+)\\("+Translator.get(Translator.LEVEL)+" (\\d+)\\)", desc, 2);
                String artifact = Translator.translate( data[0].trim());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.