I am trying to use XML DOM Parser on Blackberry. However i couldn't get the root element.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
InputStream is = getClass().getResourceAsStream("abcd.xml");
DocumentBuilder builder = factory.newDocumentBuilder();
Document dom = builder.parse(is);
Element root = dom.getDocumentElement();
NodeList rootTag = root.getElementsByTagName("myRootElementName");
Node subTag = rootTag.item(0);
items = subTag.getChildNodes();
When i debug the code above, rootTag.item(0); is returning null.
Can anybody help me please.开发者_开发知识库 (The same code works fine on Android).
Thanks.
Try NodeList rootTag = dom.getElementsByTagName("myRootElementName");
Replace root
with dom
. Waiting for your responce.
精彩评论