How to format an .XML file?
-
I’m sorry this response will provide no quick answer.
Firstly, though, I wonder why the migration from Windows 7 to Windows 10 has produced this change? That sounds odd to me. If you take you xml, bunched up on Windows 10, to a Windows 7 machine, does it display more to your liking? I would be surprised if that’s true. My suspicion is that the file just does not have the white space in it to formatting it as you would like.
How and where is the XML generated? Is it possible that logic has changed? I recall some processors having options on the save of the XML to determine how compact the output should be.
A quick and dirty way to line break an XML file is to replace all instances of >< with >\r\n<
Be wary thought that this can actually change your XML in a meaningful way. For instance, this bit of text and tags:
<p>In the word de<b><i>ci</i></b>ded, the middle syllable is stressed.</p>
… is entirely legitimate XML, and differs from this bit:
<p>In the word de<b>
<i>ci</i>
</b>ded, the middle syllable is stressed.</p>The only completely safe way to add white space where it does not matter would be to use a processor that actually knows the XML’s schema to do the processing.
-
@Jon-Oliver Thank you for your reply.
I have downloaded a program which contains .XML files. In win 7 the file has the usual neat and easily readable XML format but now in Win10 as I said before the text is one long line. I tried using Word Wrap but that breaks the line to the size of the window, it does break it into nice neat paragraphs.
I am afraid I cannot go back to Win 7 since all my PC’s now run Win 10. I have done nothing to the file, simply copied it from inside the program and dragged it to the NotePad++ window.
I think I have found a way round the problem. I have my .XML files stored on a USB stick; on another Win10 PC I have copied the file to the desktop and dragged it into the Notepad++ window - it opens in the usual neat format. So I will do my editing on that PC and then copy the file into the required program via a USB stick.
My suspicion is there is a setting somewhere in the program which can be used to switch the text format from line to paragraph. Unfortunately I do not know enough to be even slightly dangerous so I will use the “2PC route”.
I appreciate your hep and reply.
Thank you,
Clive Drake
-
Hi Clive,
I don’t know whether this will solve your problem, but you could try the “XML Tools” plugin, where you can select the option “Pretty print”.
B. -
If you have a tenable workaround – great. Something about the scenario does not make sense to me. Can you give me a “problem file” for me to look at? I have Win7 and Win10 installs and could maybe see what the difference is, as well as really see what whitespace is in the file.
-
Thank you for the offer, much appreciated. How can I send the files to you? This forum does not seem to allow attachments.
Clive
-
Just email it to me: My email address is g-r-i-n-d-e-r prefixed to a 2-1-1-2, but without any dashes, and at a popular google-based email service.
-
Thank you for your interest and apologies for the delay in replying. A friend has told me I should use the setting in the Languages tab to select .XML and it is sorted.
At present the PC which has the XML file which I want to edit is in pieces so I cannot see if this works. I will tell you if this is the answer as soon as I can.
Thank you,
Clive
-
Fair enough.
-
Hi, I have also had this problem, and while the “Pretty Print” workaround works, it is slightly painful to have to do this for every XML file I open…
This happened to me both on my old Win 7 and now my Win 10 - so my suspicion is it was related to an update to Notepad++ rather than OS?
The fix @Clive-Drake mentioned regarding changing the language does not make a difference to layout.
-
@Todd-Milne
if the file doesn’t contain proper end of line chars (windows uses “carriage return” + “line feed”) it is
displayed as a single line in npp.
Click on show all symbols to verify.Cheers
Claudia -
if the file doesn’t contain proper end of line chars (windows uses “carriage return” + “line feed”) it is
displayed as a single line in npp.NPP happily handles Windows (CR+LF), Linux (LF) and classic Mac (CR) line endings even in mixed form. Maybe some plugin does odd stuff here?