• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issues with XML \r\n

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not know anything about xml but I have to write meta data so I have been using xml notebook.  This was working fine for me until a couple of days ago when it startd adding \r\n's at every line break when I saved it.  If I  remove the \r\n's, xml editor can open the meta data, but the lines are gone if I open it in a text editor.  

Example of a FEMA meta template that gets messed up when saved:
this is what it should  look like

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
 <idinfo>
   <citation>
     <citeinfo>
       <origin>Flood County GIS Department</origin>
       <pubdate>20141101</pubdate>
       <title>Basemap Framework Submission for FLOOD COUNTY, USA</title>
<edition>Version 2.3.3.2</edition>
       <geoform>FGDC-Framework-Basemap</geoform>


this is what it looks like after I save it.

<?xml version="1.0" encoding="utf-8"?>\r\n<metadata>\r\n  <idinfo>\r\n    <citation>\r\n      <citeinfo>\r\n        <origin>Flood County GIS Department</origin>\r\n


Any idea what is happening and is there any way to fix the meta data that was saved in a weird format?

Thanks for any help you can give me.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

How strange. Don't know. It looks as though you had written that XML on Windows and transported it to a Unix‑like box, which uses \n alone as a line end, and your editor is falling over the unfamiliar characters. It also looks as though you were displaying the individual characters, and your XML file maybe isn't corrupt or anything. Have you got any strange options about encodings?
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is an issue with your XML editor. Which program are you using?

I recommend using Notepad++ with the XML Tools plugin for editing XML.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:It looks as though you had written that XML on Windows and transported it to a Unix‑like box, which uses \n alone as a line end, and your editor is falling over the unfamiliar characters.



Well, actually... you can use \r\n or \n in an XML document but a conformant XML parser will normalize either of them to just \n when it reads the document. And usually those line-ending characters are just so that people can read the document more easily, the application which uses the documents normally ignore them. So you've only got a serious problem if the application which uses the document is rejecting or mishandling it.

However, yeah, it's nice for people to be able to read an XML document sometimes.

By the way I searched the web for "xml notebook" and everything I get back is about "XML Notepad". Are you actually using XML Notepad or is there an XML Notebook which the web doesn't know much about?
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did say, ”Don't know.”
 
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:By the way I searched the web for "xml notebook" and everything I get back is about "XML Notepad". Are you actually using XML Notepad or is there an XML Notebook which the web doesn't know much about?


I happen to have XML Notepad 2007 on my workstation, tried creating the same document as you show, and the file does have non-printing CR and LF characters at the end of each line, but when opening the file using Notepad++, XMLSpy, Eclipse, VSCode, etc., the document renders fine.  How are you viewing the file after you save it?

The only time I see the CR and LF characters is when I specifically enable showing non-printing characters - for example with Notepad++:



Also, your example is not properly formed - it is missing closing tags for citeinfo, citation, idinfo, and metadata elements.  Maybe you didn't post the complete document?

 
reply
    Bookmark Topic Watch Topic
  • New Topic