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.
精彩评论