Java HTML Jsoup Element getTextFromMultipleSelect(Element doc, String location, String locationValue)

Here you can find the source of getTextFromMultipleSelect(Element doc, String location, String locationValue)

Description

get Text From Multiple Select

License

Open Source License

Declaration

public static String getTextFromMultipleSelect(Element doc, String location, String locationValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.jsoup.nodes.Element;

public class Main {
    public static String getTextFromMultipleSelect(Element doc, String location, String locationValue) {
        String[] locations = location.split(",");
        String[] locationValues = locationValue.split(",");
        Element currentElement = doc; // Space to store the current element
        int counter = 0;
        for (int i = 0; i < (locations.length); i = +2) { // Location will be always a multiple of two
            if (currentElement == null) {
                break;
            } else {
                currentElement = currentElement
                        .select(locations[i] + "[" + locations[i + 1] + "=" + locationValues[counter] + "]")
                        .first();/*from   w  ww . j  a  v  a  2  s .c  o  m*/
                counter += 1;
            }
        }
        String result = (currentElement != null) ? currentElement.text() : "none";
        return result.trim();
    }
}

Related

  1. getSingleElement(final Elements elements)
  2. getSrcOrRelFromImageElement(Element imgElm)
  3. getString(Elements td, int i)
  4. getTextContent(Element node)
  5. getTextFromAClass(Element doc, String location)
  6. getTextFromNodeIfAvailable(Element doc)
  7. getTextFromNodeSelect(Element doc, String location, String locationValue)
  8. getTitle(Element el, String[] titles)
  9. getUserId(Element authorElement)