Code example for Attr

Methods: setValue

0
      Element wl = doc.createElement("wordlist");
      rootElement.appendChild(wl);
       
      // Value list attribute 
      Attr attr = doc.createAttribute("id");
      attr.setValue(Integer.toString(id));
      wl.setAttributeNode(attr);
      id++;
       
      // Word List file path 
      Element wlFilePath = doc.createElement("wlfilepath");
      wlFilePath.appendChild(doc.createTextNode("tests/test.dwa"));
      wl.appendChild(wlFilePath);
       
      // Word List description 
      Element wlFileDesc = doc.createElement("wlfiledesc");
      wlFileDesc.appendChild(doc.createTextNode("Testinis failas"));
      wl.appendChild(wlFileDesc);
       
      // write the content into XML file