my dog learned polymorphism
The moose likes XML and Related Technologies and the fly likes about charset on XML Dom Object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "about charset on XML Dom Object" Watch "about charset on XML Dom Object" New topic
Author

about charset on XML Dom Object

chao cai
Ranch Hand

Joined: May 26, 2005
Posts: 154
why some XML String with the encoding statement(encoding="GB2312") parse by dom object SUN JDK1.4 provided will get wrong characters,but the same XML String with the encoding statement(encoding="GBK") everything is OK?
By the way,the Dom Object got the XML String by String inputstream.

StringBufferInputStream instream = new StringBufferInputStream(XML_STRING);
try {
DocumentBuilderFactory domfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dombuilder = domfactory.newDocumentBuilder();
doc = dombuilder.parse(instream);
} catch (Exception e) {
throw new ParseException(e.getMessage());
}


Also, the DOM object got the XML String directly from the file,everything is ok, in this case you can use any encodings.


SCEA<br />SCJP 1.2<br />SCBCD<br />MCSD<br />IBM Certified Specialist RUP v2003<br />IBM Certified Solution Designer OOAD vUML2<br /> <br />Phone Number:86-010-82776427
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 10895
    
  26

Moved to XML and Related Technologies.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: about charset on XML Dom Object
 
Similar Threads
can i use DOM.. to see if xml is well formed
Creating JDOM Document from a String
? - Is there a way to validate 1 XML record at a time, using the SAX or other parser!
problem parsing xml string using dom parser
problem parsing xml string using dom parser