Insert new lines in XML text using Visual Studio.

UPDATE: I've recently was adviced that I can use VS command Edit/Advanced/Format Document(Ctrl-K,Ctrl-D) and it does better formating.

I 've got XML files as one long string, not formatted. IE explorer shows them nicely with all indentation and ablility to collapse parts.
However to edit or compare files using Windiff or Winmerge it will be convinient to have them with short lines, e.g. each element in a new line.

Fortunately VS has ability to insert new lines in replace operation.
1.Click Ctrl-H
2. Tick "Use Regular Expressions"
3. In Find specify [>]
4. In Replace specify \0\n.
5 Click "Replace All"
After all XML ">" characters a new line will be inserted.

I also used the same approach to insert line breaks into HTML files.

posted @ Monday, January 21, 2008 7:48 PM

Print

Comments on this entry:

# re: Insert new lines in XML text using Visual Studio.

Left by Chris B at 4/9/2009 8:07 PM
Gravatar
you can use the <para> tag to mark text as a new paragraph. This puts is on to a new line.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345