Why does XML look differently in notepad++ and notepad? [closed]

旧街凉风 提交于 2019-12-13 11:10:56

问题


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!


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/16201869/why-does-xml-look-differently-in-notepad-and-notepad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!