• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about charset on XML Dom Object

 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11887
203
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to XML and Related Technologies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic