我解析一個xml數據來自一個字符串。我使用下面的代碼解析: -xml從字符串解析
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder docBuilder = docBuilderFactory
.newDocumentBuilder();
docBuilder.isValidating();
ByteArrayInputStream ba= new ByteArrayInputStream(connect.content.getBytes("UTF-8"));
doc = docBuilder.parse(ba);
doc.getDocumentElement().normalize();
NodeList locationStatus = doc.getElementsByTagName("street");
for (int i = 0; i < locationStatus.getLength(); i++) {
Node locationValue = locationStatus.item(i).getChildNodes().item(0);
_node.addElement(locationValue.getNodeValue());
}
String [] nodeString = new String[_node.size()];
_node.copyInto(nodeString);
add(new LabelField(nodeString.length+""));
但這段代碼是給錯誤,我不沒有錯誤所在。
請幫我
在此先感謝
什麼是錯誤的細節?你有沒有堆棧跟蹤? – 2010-07-07 16:46:16
你能發佈錯誤消息和堆棧跟蹤嗎? – 2010-07-07 16:47:28
它也將有助於查看您試圖解析的XML – 2010-07-07 16:51:16