我解析一个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