I'm trying to write to an XML file, within my XML file I have:
<user>
<name></name>
</user>
And the method I can to write to the XML file:
public void WriteToXML() throws ParserConfigurationException, IOException, SAXException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputStream);
Element element = doc.getDocumentElement();
element.normalize();
NodeList nList = doc.getElementsByTagName("user");
Node node = nList.item(0);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element2 = (Element) node;
if(element2.getTagName() == "name")
{
element2.setNodeValue("SFDSFSDF");
}
}
}
However, the method gets called but for some reason it doesnt actually write to the XML file because when I read it their isn't actually anything within the XML?