Package org.jsoup.nodes

Examples of org.jsoup.nodes.Element


        final Elements hs = doc.select("h1, h2, h3, h4, h5");

        listBuilder.append("<ul class='b3-solo-list'>");
        for (int i = 0; i < hs.size(); i++) {
            final Element element = hs.get(i);
            final String tagName = element.tagName().toLowerCase();
            final String text = element.text();
            final String id = "b3_solo_" + tagName + "_" + i;

            element.before("<span id='" + id + "'></span>");

            listBuilder.append("<li class='b3-solo-list-").append(tagName).append("'><a href='#").append(id).append("'>").append(text).append(
                "</a></li>");
        }
        listBuilder.append("</ul>");

        final Element body = doc.getElementsByTag("body").get(0);

        content = listBuilder.toString() + body.html();

        article.put(Article.ARTICLE_CONTENT, content);
    }
View Full Code Here


            final String test = anchors.get(j).attr("href");
              final File testFile =  new File(this.reportsDir, test);
              final Document testHtml = parseHtml(testFile);
              final List<Element> errors = testHtml.getElementsByClass("error");
              for(int k = 0 ; k < errors.size() && logErrorsToConsole() ; k++) {
                final Element error = errors.get(k);
                final Elements fitLabel = error.getElementsByClass("fit_label");
                if(!fitLabel.isEmpty()) {
                  logFitNesseError(test, fitLabel.text());
                }
                final Elements fitStacktrace = error.getElementsByClass("fit_stacktrace");
                if(!fitStacktrace.isEmpty()) {
                  logFitNesseError(test, fitStacktrace.text());
                }
              }
              final List<Element> details = testHtml.getElementsByClass("exception-detail");
              for(int k = 0 ; k < details.size() && logErrorsToConsole() ; k++) {
                final Element detail = details.get(k);
                if(detail.hasText()) {
                  logFitNesseError(test, StringUtils.substringAfter(detail.text(), SlimServer.EXCEPTION_TAG));
                }
              }
          }
        }
  }
View Full Code Here

  public List<Account> getAccounts() {
    List<Account> vAccounts = new ArrayList<Account>();
    BankResponse vAccountsRequest = mBankClient.get(new BankRequest(ACCOUNTS_URL));
    String response = vAccountsRequest.body();
    Document doc = Jsoup.parse(response);
    Element el = doc.getElementById("summaryImageHeaderRow");

    if (el != null) {
      Account account = new Account();
      account.setName(el.getElementById("headerSectionLeft").select("span.cardTitle a").text());
      account.setAccountType(AccountType.LIABILITY);
      Element link = el.select("div.summaryTitles a").first();
      account.setAccountNumber(link.text());
      account.setCurrency(Currency.getInstance("SEK"));
      account.setId(parseAccountId(link));

      String balance = doc.getElementById("colOSBalance").select("div.summaryValues").text();
      balance = balance.replaceAll("[^\\d-,]", "").replace(",", ".");
View Full Code Here

  @Override
  public Pagination parsePagination(BankResponse pBankResponse) {
    Pagination pagination = new Pagination();

    Document doc = Jsoup.parse(pBankResponse.body());
    Element element = doc.select("#viewPeriod option[selected]").first();

    Element previous = element.previousElementSibling();
    if (previous != null) {
      pagination.setPrev(Integer.parseInt(previous.val()));
    }

    Element next = element.nextElementSibling();
    if (next != null && isDateWithinRange(next)) {
      pagination.setNext(Integer.parseInt(next.val()));
    } else {
      pagination.setNext(-1);
    }
    pagination.setFirst(0);
    pagination.setLast(Integer.parseInt(element.lastElementSibling().val()));
View Full Code Here

  private List<Transaction> parseTransactions(BankResponse pResponse) {
    List<Transaction> transactions = new ArrayList<Transaction>();

    Document doc = Jsoup.parse(pResponse.body());
    Element transactionTable = doc.getElementById("table-txnsCard0");
    if (transactionTable != null) {
      for (Element transaction : transactionTable.select("tbody tr")) {
        transactions.add(parseTransaction(transaction));
      }
    }
    return transactions;
  }
View Full Code Here

    return params;
  }

  private List<Account> parseAccounts(Document pDocument) {
    List<Account> accountList = new ArrayList<Account>();
    Element element = pDocument.getElementById("balanceForm:accountsList");
    Elements accounts = element.select("td a[href=#]");
    Matcher vMatcher;
    for (Element rawAccount : accounts) {
      Account account = new Account();
      account.setAccountNumber(rawAccount.text());
      vMatcher = PATTERN_ACCOUNT_ID.matcher(rawAccount.attr("onclick"));
View Full Code Here

 
  private static Element findFirstByTag(Element current, String [] tags, int index) {
    if(index < tags.length) {
      Elements elements = current.getElementsByTag(tags[index]);
      for(Element element : elements) {
        Element result = findFirstByTag(element, tags, index + 1);
        if(result != null)
          return result;
      }
      return null;
    }
View Full Code Here

        || attributeKey.equals(HtmlSpecialAttributes.SPECIAL_ATTRIBUTE_TEXT));
  }

  @Override
  public String getAttribute(String attributeKey) {
    Element element = getJsoupElement();
    return getAttributeValueOfJSoupElement(element, attributeKey);
  }
View Full Code Here

      Elements e = doc.getElementsByTag("div");
      Elements divInhaltElements = e.select("#inhalt");
      if (divInhaltElements == null || divInhaltElements.size() == 0) {
        System.out.println("no div with id=\"inhalt\"!");
      } else {
        Element divInhalt = divInhaltElements.first();
        result = parseContent(divInhalt);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

            document = Jsoup.parse(inputString);
        }
        Elements elements = document.select(expression);
        int size = elements.size();
        for (int i = 0; i < size; i++) {
            Element element = elements.get(i);
            if (matchNumber <=0 || found != matchNumber) {
                result.add(extractValue(attribute, element));
                found++;
            } else {
                break;
View Full Code Here

TOP

Related Classes of org.jsoup.nodes.Element

Copyright © 2018 www.massapicom. 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.