java - XML DOM createchild takes Node instread of Element -


I am making XML using the DOM below using online examples,

  DocumentBuilderFactory docfac = DocumentBuilderFactory.newInstance (); DocumentBuilder docb = docFactory.newDocumentBuilder (); Document doctor = docb.newDocument (); // root element root element = (element) doc.createElement ("test"); Doc.appendChild (rootElement); // Compiler Error ...   

AppEngine node takes an object, not element object. I was trying to use node, but it seems that there is no way to set up the attribute, so I can not really use nodes.

Any help really appreciates it.

Thank you.

Please confirm the package you imported: import org.w3c Dom.Document and import org.w3c.dom.Element; and docfac.newDocumentBuilder () ;

Type is not required to enter org.w3c.dom.Element because doc.createElement ("TEST") Org.w3c.dom.Element which is a sub-interface of org.w3c.dom.Node .
  org.w3c.dom.Element rootElement = doc.createElement ("TEST"); Doc.appendChild (root element)    

Comments