开发者

Blackberry XML DOM Parser Problem (getDocumentElement())

开发者 https://www.devze.com 2023-02-22 22:02 出处:网络
I am trying to use XML DOM Parser on Blackberry. However i couldn\'t get the root element. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消