xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Ruiz Martínez <...@dif.um.es>
Subject Problem reading newline characters and rewriting them
Date Tue, 12 Jul 2005 20:19:13 GMT
Hello!

I have a class that reads a xml file. Sometimes the document that I 
read, it has the following format:
<root>
<a>
</root>

sometimes the document has the following form:
<root>[]<a>[]</root>
That is, sometimes the newline is coded with a only bytes, and sometimes 
with two bytes.

The problem is that I would like to parse the document and then re-write 
it in the same wave that I read it.
However, with the way that I'm using the result is always as the second 
form.
The code is:

DOMParser parser = new DOMParser();
parser.parse("A.xml");
DocumentImpl document = (DocumentImpl)parser.getDocument();

//do some treatment...
....

OutputFormat formato  = new OutputFormat(document);
XMLSerializer ser = new XMLSerializer(sw, formato);
ser.serialize(document);
System.out.println(sw.toString());
           
FileOutputStream fout=new FileOutputStream("B.xml");
fout.write(sw.toString().getBytes());
fout.close();


Could you help me to solve my problem?
Regards,
Antonio.

-- 
------------------------------------------------------
Antonio Ruiz Martínez
Faculty of Computer Science-University of Murcia
30071 Murcia - Spain
e-mail: arm@dif.um.es or arm [at] dif [dot] um [dot] es
------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Mime
View raw message