-2

UPDATE

Ok, so the reason the files look differently is because the EOL(End Of Line) is different in UNIX and Windows format. Notepad can not handle UNIX EOL so it places the XML all on one line. Notepad++ handles both so it knows how to properly format the file when displaying it. Changing the EOL in Edit->EOL Conversion (+1 to Uberfuzzy for noting that) to windows will make it so notepad can view the file properly.

ORIGINAL POST

Ok, so this question spawns off of another question I created, which I will link below, and I want to know why XML works the way it does. So, I have an XML file open in notepad++ that looks like this:

<?xml version="1.0"?>
<settings>
    <tag_1>some tag content</tag_1>
    <tag_2/>
</settings>

the same file opened in good old simple notepad looks like this

<?xml version="1.0"?><settings> <tag_1>some tag content</tag_1> <tag_2/></settings>

Now, back in notepad++ I use "Plugins->XML Tools->Linearize XML" and then "Plugins->XML Tools->Pretty print (XML Only - with line breaks)" (kudos to How to format XML in Notepad++? for helping me figure that out) and now, that file looks the same as it did before in notepad++ but in notepad it now looks like

<?xml version="1.0"?>
<settings>
    <tag_1>some tag content</tag_1>
    <tag_2/>
</settings>

My other question, which can be found here How to load XML in ACE? only loads XML properly IF it looks correctly in notepad. So why does XML look differently in notepadd++ and notepad? Is there a character that I am unaware of being used? Or is it notepad++ formatting the XML automatically because it knows how to read tags? I do not know... Any help would be appreciated!

Community
  • 1
  • 1
user2115945
  • 223
  • 3
  • 12
  • 1
    You answered your own question: notepad++ is formatting the XML automatically because it knows how to read tags – antlersoft Apr 24 '13 at 20:51
  • I do not like making assumptions about how programs work, it helps to have a second opinion :) – user2115945 Apr 24 '13 at 21:04
  • 2
    For the record, in case you didnt find it: Edit -> EOL Conversion – Uberfuzzy Apr 25 '13 at 07:42
  • My file was in UNIX format, changing it to windows fixed the formatting in notepad. I guess another potential cause for this problem could be that when the file was initially created for whatever reason it saved in UNIX format. I'll go check how I save my XML files, and why they might be formatted as UNIX. Thanks Uberfuzzy. – user2115945 Apr 25 '13 at 11:14

2 Answers2

3

It is because of the linebreaks which make a new line in your XML, plain old notepad needs Windows linebreak.

For windows it is : \r\n

Andres L
  • 683
  • 9
  • 20
  • While that is helpful, it does not really tell me why the linebreaks in my XML are not working properly in notepad. Some other guys on the page explained it. Thanks anyway for the help! – user2115945 Apr 25 '13 at 11:17
2

Notepad uses the standard Windows style newlines (CRLF) while, Unix uses (LF). I think your XML file is a Unix formatted text file, that's why Notepad is not displaying it properly. And after you used the plugin in Notepad++ it must have added the system specific new line in your file, but this an assumption I am making.

hyde
  • 2,525
  • 4
  • 27
  • 49
  • 2
    About Notepad: While Notepad is a piece of junk that Microsoft slaps in every version of Windows without any improvement, Notepad++, on the other hand, is a very nice feature-rich text editor. I refrain from using Notepad as much as possible because it just does not have any cool features, that I can get from say Notepad++ or Sublime Text. – hyde Apr 24 '13 at 21:18
  • Oh wow, I didn't know that. Also Uberfuzzy mentioned EOL Conversion and when I checked it my file is in UNIX format. Changing it to windows fixed the problem. Also, while it is true that notepad is very simple, sometimes it helps to look at unformatted text files. It helps me see how exactly a file looks so I know how to read it properly. For XML, that is not always the case because generally I am parsing it using nodes, but in this particular case I am reading it as text so I do not need auto formatting. Just my 2 cents on notepad, there is reason to use it every now and again in my opinion. – user2115945 Apr 25 '13 at 11:05