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.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
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:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910