Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add line breaks in large XML file in one line

Tags:

xml

notepad++

I have a large XML file in one line.

How can I add a line break for each tag so that it is not in one line in my editor?

I am using notepad ++

Thanks in advance

like image 674
asmundur Avatar asked Aug 02 '12 14:08

asmundur


People also ask

How do you insert a line break in XML?

use <br/> ; or.

Are line breaks allowed in XML?

XML does not require a specific form of line break, so you can use whatever is convenient (carriage return, linefeed, or a combination) when creating an XML file. XML parsers will do the right thing largely because they're parsing on tags, not records - so whatever line break you're using is just whitespace to XML.

Does New Line matter in XML?

It depends on how you're reading and writing the XML. - then there's nothing to worry about. Your input likely doesn't have any other XML in it so it's just cleaner to not mess with XML at all. If tags are being worked with manually, it's still cleaner to just have a line break, if you ask me.


3 Answers

From the menu , go to

Plugins --> XML Tools --> Pretty Print 

If you don't have the XML tools plugin installed, you can download it by clicking on

Plugins --> Show Plugin Manager 

And choosing XML Tools

like image 130
Icarus Avatar answered Oct 18 '22 04:10

Icarus


Perhaps that will be useful to someone:

How can I add a line break for each tag so that it is not in one line in my editor?

To do that to several files, automatically, I use XmlLint:

xmllint YOUR_FILE.xml --format

XmlLint is available in the Kubuntu/Ubuntu packages, and also can be downloaded for several operating systems in: ftp://xmlsoft.org/libxml2/

like image 34
Ganton Avatar answered Oct 18 '22 03:10

Ganton


instead of of doing this : Plugins --> XML Tools --> Pretty Print , you can use this usefull shortcut : Ctrl + Alt + shift + B

like image 37
Monsif EL AISSOUSSI Avatar answered Oct 18 '22 04:10

Monsif EL AISSOUSSI