开发者

W3C dom api in Java

开发者 https://www.devze.com 2022-12-26 01:44 出处:网络
Take a look at the example code... NodeList folderNodes = do开发者_C百科cument.getElementsByTagName(\"Folder\");

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

精彩评论

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