Java DOM getElementByID

前端 未结 2 586
轻奢々
轻奢々 2021-01-07 08:07

I am using DOM parser in Java to add child nodes into existing nodes.

My XML is


          


        
2条回答
  •  情深已故
    2021-01-07 08:49

    getElementById is specifically for retrieving DOM elements by their id attribute. Try this instead:

    this.widgetDoc.getElementById("legendNode").appendChild(myNode);
    

    For other ways of retrieving DOM nodes, look into querySelector and querySelectorAll.

提交回复
热议问题