上面是一个XML格式字符串,怎么用java解析成为一个数组
{5,test2, test2, jn@163.com, 0}
public static LinkedList uc_unserialize(String input){
LinkedList<String> result = new LinkedList<String>();
DOMParser parser = new DOMParser();
try {
StringReader cc = new StringReader(input);
InputSource bb = new InputSource(cc);
parser.parse(input);
Document doc = parser.getDocument();
NodeList nl = doc.getChildNodes().item(0).getChildNodes();
int length = nl.getLength();
for(int i=0;i<length;i++){
if(nl.item(i).getNodeType()==Document.ELEMENT_NODE)
result.add(nl.item(i).getNodeValue());
}
} catch (SAXException e) {
} catch (IOException e) {
}
return result;
}
代码执行后,doc 始终是null