Link to home
Create AccountLog in
Avatar of ITApprendista

asked on

Removing indentation from XML or setting it so that it does not automatically indent

I'm writing a custom program that edits xml files which are settings files for a program we use.  I've figured out how to change all the nodes & use XPath to locate the ones I need to edit.

Basically there is a method I wrote which creates a new XML (Configuration) file based off a template.  The problem is...the program by default uses XML files that have no indentation, no returns, no tabs.  So, when I open the XML template then save it as a new job I get a fully indented & formatted XML file.  All the info is correct but when you open this indented and formatted XML file in the program the program doesn't like it. there any way I can open and edit an XML file but NOT automatically indent it?

I'm programming all this with and using the DOM document properties to edit the XML files.
Avatar of Snarf0001
Flag of Canada image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of ITApprendista


This works except:  For some reason the first line the template is
<?xml version="1.0"?>
But after editing it becomes
version="1.0"?> which is enough to throw the whole thing off.