xml looks not as expected
-
Hello
I am new in Notepad++
I only wanted to make a little thing with xml. So I tried out Notepad++. But the behavior is not as expected.
I opened an xml-File (*.xml):
This is the content, when I open it with InternetExplorer 8:
-> https://www.bilder-upload.eu/bild-0faae4-1539017598.png.html
But when I open it with Notepad++ and choose “xml” as language I get this:
-> https://www.bilder-upload.eu/bild-bf447e-1539017591.png.html
What is different? Answer: For example in the Internet Explorer it shows
-> <Question><HTML><HEAD></HEAD> <BODY BORDER-BOTTOM: blue thin;But in Notepad++ it shows:
-> https://www.bilder-upload.eu/bild-5a90dc-1539018661.png.htmlAlso the Line break is different.
Is there a way to get what I want? Would appreciate your help. Thank you.
-
Internet explorer is parsing it, and showing you a specially-rendered output with the results of the parsed XML. Notepad++ is showing you the raw source of the XML.
If you looked with windows builtin notepad.exe, it would look similar to what you see in Notepad++.
Your XML really does use the entities, because it’s XML wrapping HTML. Notepad++ (and notepad) will show you what’s really there. Apparently, whoever gave you the XML-wrapping-HTML wanted the XML parsing to not try to parse the HTML as well (which is reasonable: if I had a database, where an HTML string were one part of the data, and I wanted to export that database to XML, I would want to encode the HTML, so that it would be one “object” in the XML, rather than being a whole bunch of nested objects; it’s only after I’ve extracted that encoded-HTML out of the XML that I’d want to decode it before doing something with the HTML.)
Internet Explorer, on the other hand, is a rendering engine. It sees the
<
and knows that it’s supposed to render that as<
.I believe both tools are working as designed.
-
I forgot to mention, regarding the line breaks: the source XML doesn’t have the line breaks, which is why Notepad++ isn’t showing line breaks. IE takes whatever XML it is given, and “prettifies” it, adding line breaks and indents and controls to be able to collapse/uncollapse blocks.
IE is meant to render the underlying data in a reasonable way. Notepad++ is meant to edit the source that’s physically in the file.
-
Thank you for your answer.
What I am looking for is an editor that shows xml like IE does. (That means an editor which makes the rendering.) But I can not use IE, because I can not edit this xml file with IE.
So am I right, that Notepad++ is not able to support what I want. Right?
Do you know any programme, that shows xml like IE but supports editing?
-
I’m sure there must be XML WYSIWYG editors, but I cannot point you to any.
If you install the XML Tools plugin for Notepad++ (available in the plugin manager; I’d have to do a search to figure out where it is if you don’t have/want the plugin manager), then you can at least format the XML in a “pretty” way (XML Tools > Pretty Print (XML Only - with line breaks)).
If you are really wanting to edit the HTML that’s stored inside the XML, after prettifying the XML, you could select the HTML contents of one of the XML tags, and then convert those entities to text, so it will look like HTML to you (select, then XML Tools > Convert Selection Text to XML (or vice versa).
-
A simplified example:
-
I start with
<Collection><Content><HTML><head><title>name</title></head><body><p>rank and serial number</p></body></HTML></Content></Collection>
-
I run the Pretty Print (line breaks)
<Collection> <Content><HTML><head><title>name</title></head><body><p>rank and serial number</p></body></HTML></Content> </Collection>
-
I select everything inside the
<Content></Content>
pair -
I run Convert Selection Text to XML on that selection
<Collection> <Content><HTML><head><title>name</title></head><body><p>rank and serial number</p></body></HTML></Content> </Collection>
-
If wanted, I can Pretty Print the HTML as well. (It might still be selected for you; or you can Pretty Print the whole document)
<Collection> <Content> <HTML> <head> <title>name</title> </head> <body> <p>rank and serial number</p> </body> </HTML> </Content> </Collection>
At this point, you can edit and save to your heart’s content. However, it should be pointed out that whatever is using your XML probably expects the embedded HTML to be escaped, so you will probably have to select what’s inside the CONTENT again and …
-
Run Convert Selection XML to Text on what’s inside the CONTENT
<Collection> <Content> <HTML> <head> <title>name</title> </head> <body> <p>rank and serial number</p> </body> </HTML> </Content> </Collection>
-
-
Thank you, but this method is not usefully for me.
I will generate a .*txt with the help of some progamme code (automatically), which looks like your point “4.”. This xml-file will be about 2-10 MB.
After, I will have to convert the content of this txt into a real *.xml which then, I guess, looks like your point “1.”, when I open this *xml after the conversion with a notepad.
-
Sometimes, Notepad++ isn’t the best tool for the job…
Though I think if you’re able to automate 1-5 in some script, you could do the edits in Notepad++, then automate the reverse to get the XML back into a form that can be used by whatever else is using your XML. If the output of edit after step5 is still compatible with your other system – which isn’t outside the realm of possibility, assuming that tool followed the philosophy of “Be conservative in what you send, be liberal in what you accept” ↗ – then you might be able to use the output of the edit directly, rather than having to reconvert back…
Good luck, sorry I wasn’t more help.
-
Hello
I tried to install XML Tools. But I was not able to do it.
(Windows 7, 32 bit) I tried it also as Administrator.https://www.bilder-upload.eu/bild-29636d-1539075881.png.html
???