Helper method to extract an empty element from a string containing XML
(String xml, String elementName)
| 179 | * containing XML |
| 180 | */ |
| 181 | String getEmptyElement(String xml, String elementName) { |
| 182 | // find the index of "<elementName"; find the next ">" |
| 183 | int start = xml.indexOf("<" + elementName); |
| 184 | int end = xml.indexOf(">", start); |
| 185 | |
| 186 | // get the range between the two indices |
| 187 | StringBuffer xmlBuf = new StringBuffer(xml); |
| 188 | String substr = xmlBuf.substring(start, end + 1); |
| 189 | if(DEBUG) { |
| 190 | Out.prln("start=" + start + "; end=" + end + "; substr=" + substr); |
| 191 | } |
| 192 | |
| 193 | return substr; |
| 194 | } // getEmptyElement |
| 195 | |
| 196 | } // class TestFiles |
no test coverage detected