1

I'm trying to write an xml file using javascript like this:

 var root = new ActiveXobject("Microsoft.XMLDOM");
 var Plnode = root.createProcessingInstruction("xml", "version ='1.0' encoding='utf-8'");
 var Firstnode = root. createElement("Project");
 var Input_data = root. createElement("Input_data");

When written, the data is written all in one line.

<?xml version="1.0" encoding="utf-8"?>
<Project><Input_data></Input_data></Project>

Is there a way to print this in a prettified manner instead, like below?

<Project>
 <Input_data>
 </Input_data>
</Project>
Shadow
  • 8,749
  • 4
  • 47
  • 57
G.H.LEE
  • 11
  • 2
  • Cleaned up some mild readability problems, but overall this seems pretty well written as you've shown what's happening and what you would like to happen in a concise manner. – Shadow Jan 16 '18 at 03:04
  • Is there a reason why you want to do this? You could try a utility like [code-prettify](https://github.com/google/code-prettify) – Phil Jan 16 '18 at 03:23

0 Answers0