请使用XML解析器 错误的写法: - int start = xml.indexOf("<name>") + "<name>".length();
- int end = xml.indexOf("</name>");
- String name = xml.substring(start, end);
正确的写法: - SAXBuilder builder = new SAXBuilder(false);
- Document doc = doc = builder.build(new StringReader(xml));
- String name = doc.getRootElement().getChild("name").getText();
|
|