Thursday, 5 September 2013

Capturing Id attribute to an Array by JSoup?

Capturing Id attribute to an Array by JSoup?

I'm using the library Jsoup, is that I have a string with two HTML
components with the attribute ID to all, I want to do is capture the two
IDs in an array.
String chain = "<div id='stylized' class='myform' style='margin:20px auto;'>
<div id='material_comprado' > </div> ";
I was trying to use this for, but failed.
int i = 0;
Elements values = doc.getElementsByAttribute("id");
String s[] = new String[values.size()];
for(Element el : values){
s[i++] = el.attr("id");
System.out.println("==> "+s[i]);
}
Anyone can help me.

No comments:

Post a Comment