aspose file tools*
The moose likes XML and Related Technologies and the fly likes multiple lines text  in XML tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "multiple lines text  in XML tag" Watch "multiple lines text  in XML tag" New topic
Author

multiple lines text in XML tag

Steve Jiang
Ranch Hand

Joined: May 17, 2004
Posts: 107
If I put long text in multiple lines in XML tag, the display will put all stuff together. Is there any setting to keep origianl format with return to keep text as multiple lines?

For exmaple
<TEST>
1234567
1234567
1234567
</TEST>

the browser display
<TEST>
1234567 1234567 1234567
</TEST>
[ March 29, 2007: Message edited by: Steve Jiang ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18911
    
    8

Browsers change newline characters to spaces. That's just what they do. If you don't want that to happen, either put the text into a <pre> element in your HTML or replace the newline characters by <br/> elements.
Steve Jiang
Ranch Hand

Joined: May 17, 2004
Posts: 107
" Browsers change newline characters to spaces. That's just what they do. If you don't want that to happen, either put the text into a <pre> element in your HTML or replace the newline characters by <br/> elements. "


I use browser to open XML file. </br> works for HTML , but looks it doesn't work for XML.

Is there way to display return of multiple lines for XML with browser?

Thanks,
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Is there way to display return of multiple lines for XML with browser?

No, at least not without rerendering the XML in the way Paul suggests. There is nothing in the XML specification to say white space should be maintained. The examples you give are considered identical from XML's point of view, so you are at the mercy of whatever technology you use to display it as to how it is rendered.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: multiple lines text in XML tag