How to preserve newlines when formatting XML

Having trouble installing Oxygen? Got a bug to report? Post it all here.
huijzer
Posts: 3
Joined: Thu Jan 05, 2006 2:22 pm

How to preserve newlines when formatting XML

Post by huijzer »

Hi,

When I format my XML files, empty lines are removed. Is there a way to prevent this form happening. The empty lines are there for readability :-)

Before:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<test>
<node><a/></node>

<node><b/></node>
</test>
After:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<test>
<node>
<a/>
</node>
<node>
<b/>
</node>
</test>
What I would like:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<test>
<node>
<a/>
</node>

<node>
<b/>
</node>
</test>
Is this possible?

Thanks in advance for any help!

Arjan Huijzer
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

You can achieve that if you set the spaces to be preserved for the test element and to be stripped for the node element. You can set the preserve/strip spaces state for a node either using the xml:space attribute with the preserve and default as values or by adding the element name to the preserve or strip spaces element lists from Options->Preferences -- Editor / Format dialog.

Best Regards,
George
Post Reply