XML output on separate lines

Gasoline

New Member
Hi,

I have generated an XML-file with line breaks after each node according to Knowledge base solution P110416. (Inserting a text node containing a linefeed character after each node).

The generated xml file also has a doctype declaration and a stylesheet reference tag. These are still output on the same line as the root node.

Code:
<?xml version="1.0" encoding="ISO-8859-15" ?>
<!DOCTYPE MyDoc SYSTEM "MyDoc.dtd"><?xml-stylesheet type='text/xsl' href='MyDoc.xsl'?><MyDoc>
<Node1>text</Node1>
<Node2>
<SubNode></SubNode>
</Node2>
</MyDoc>

Can someone please tell me how to output the doctype tag and the stylesheet reference tag on separate lines?

Thanks!
 

tamhas

ProgressTalk.com Sponsor
The basic answer is don't do that, any of it. XML is not a line-oriented protocol and trying to make it pretty print is likely to foul up the conversation as much as anything else. Get yourself a copy of Stylus Studio or some lesser tool for looking at the XML with attractive formatting and indentation and get those line feeds out of there.
 

Gasoline

New Member
Thanks for the quick reply Tamhas!

Unfortunately, it is a requirement from a customer to recieve the file with each node on a new line. So even if this is something I should not do, is there a way to do it?
 

tamhas

ProgressTalk.com Sponsor
Inform the customer that this is *not* according to the XML standard. Some tools will accept it, but it is non-standard and not the way XML is intended to work.
 
Top