Skip to content Skip to sidebar Skip to footer

How Do I Make An Array From Jsoup Elements? (java)

How do I get the values in a piece of Html (values='valueIWant'), and have them in an Array ? I tried the following, but that didn't work: HttpEntity entity5 = response5.getEntity

Solution 1:

First of all: is your HTML parsed correctly? Can you provide the contents of defaultString? Is defaultDoc valid is there a problem with file encodings perhaps?

Assuming getElementsByAttribute actually returns some objects —note that you have a typo, value instead of values— you're currently populating the array with the descriptions of all Element-objects, not the values of the attribute. Try something like the following:

int i = 0;
String s[] = newString[values.size()];
for(Element el : values){
    s[i++] = el.attr("values");
}

Post a Comment for "How Do I Make An Array From Jsoup Elements? (java)"