0

I'm using R to produce an xml file and it is encoded in UTF-8. It looks really good in browser however looks unstructured in a text file(in the sample output it looks both good in a browser and a text file).

here is the structure in browser:

<?xml version="1.0" encoding="UTF-8"?>
-<sparesHeader>
   <partnerRef>MediaLab</partnerRef>
   <messageType>CompMaster</messageType>
   <componentClass>PSTN</componentClass>

and here is the structure in text:

<?xml version="1.0" encoding="utf-8"?>
<sparesHeader><partnerRef>MediaLab</partnerRef><messageType>CompMaster</messageType>   <componentClass>PSTN</componentClass>

Anyone have encountered something like this before?

Thanks in advance.

Lambo
  • 857
  • 3
  • 14
  • 39
  • Most browsers automatically style XML documents based on some internal style sheet (XSLT likely). But the presentation is separate from the data itself. It's just like the structure of an HTML file in text is just a bunch of words and greater-than/less-than symbols. But the browser transforms that to a page of text and images and things you can click on. It's really no different. – MrFlick Jul 03 '14 at 04:09
  • Thanks MrFlick but can I put some kind of code to make it more structured when opening in a text file? (That's one of the requirements of this task) – Lambo Jul 03 '14 at 04:47
  • It makes absolutely no sense to me to spend time worrying about how the XML looks in a file. I'd be more worried that it validates and contains the correct information. It's a data format, not a presentation format. Perhaps someone else might have a different opinion. You should add the code you use in R to make the xml as a [minimal, reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Be clear about what packages you are using. – MrFlick Jul 03 '14 at 05:40

0 Answers0