I have an XML file that I open and edit several attributes in node and then save it, but for some reason, the saved XML does not indent properly, as before.
Here is my code through which I save the XML file:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File(Path));
transformer.transform(source, result);
Although I indicated
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
XML is not indented properly, I would like to have XML in the state as before (except for the changes that were made)
Any help would be really appreciated.
Thank you very much in advance.
source
share