benstpierre
benstpierre

Reputation: 33571

W3C dom api in Java

Take a look at the example code...

  NodeList folderNodes = document.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?

Upvotes: 1

Views: 284

Answers (1)

Skrud
Skrud

Reputation: 11933

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.

Upvotes: 3

Related Questions