- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
// Gets the starting position for the endtag of the first element in text.
private int getEndTagPosition(String element, String text) {
String startTag = "<" + element;
String endTag = "</" + element;
int nestingLevel = 1;
int end = 0;
int startPos = 1;
while (nestingLevel > 0) { // loop until matching endtag is found
int start = text.indexOf(startTag, startPos);
end = text.indexOf(endTag, startPos);
if ((start == -1) || (start > end)) { // next tag is an endtag
nestingLevel--;
startPos = end + 1;
} else { // next tag is a starttag
nestingLevel++;
startPos = start + 1;
}
}
return end;
}
Lure Of Chaos 03.11.2011 15:08 # +2
guest 11.11.2011 03:24 # 0
guest 09.12.2011 18:03 # 0
guest8 09.04.2019 11:54 # −999