Ignoring Carriage Return Using DOM API

T

thelane

I am parsing an xml file with the DOM api and it is reading my
carriage returns.

When I try to output the values from the xml to a flat file, it is
going on to a new line because of the carriage return

So how do I ignore the carriage return or convert it to nothing.

Alos, how would I go on to a new line in my file.

I am using output.write, but there is no output.writeln()

many thanks
 
J

Joseph Kesselman

thelane said:
I am parsing an xml file with the DOM api and it is reading my
carriage returns.

Correct behavior. The carriage returns (and any indentation whitespace)
are part of the text content of those nodes.

If you're validating the document, some parsers can be told to suppress
"whitespace in element content" -- ie, whitespace that appears where the
DTD or Schema says character data is not expected. The xml:space
attribute may also be used in the document to help guide this; see the
XML Recommendation's section 2.10 (White Space Handling)

If you aren't validating, or if the whitespace is in a place where text
content *is* acceptable, then you're the only one who knows whether the
whitespace is meaningful or not and you have to code appropriate
handling into your application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top