开发者

W3C dom api in Java

Take a look at the example code...

  NodeList folderNodes = do开发者_C百科cument.getElementsByTagName("Folder");
  DocumentFragment node = (DocumentFragment) folderNodes.item(0);

It was very easy to do "getElementsByTagName" on the document but when I want to do this again on the DocumentFragment it seems I cannot. How do I go about furthering this query?


Use Element instead of DocumentFragment:

NodeList folderNodes = document.getElementsByTagName("Folder");
Element node = (Element)folderNodes.item(0);

NodeList subNodes = node.getElementsByTagName("OtherNodes"); // and so on...

The Element interface supports getElementsByTagName, whereas DocumentFragment is minimal and really doesn't do much.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜