java - Allowed Special Character in Transformer -


i trying send xml file server after processing has special character "佥佬佧佼a£".

currently code looks like

 public class utils {  public static string transformtostring(document activedocument) throws transformerexception{  transformerfactory tf = transformerfactory.newinstance();     transformer transformer = tf.newtransformer();     transformer.setoutputproperty(outputkeys.omit_xml_declaration, "yes");     transformer.setoutputproperty(outputkeys.indent, "true");     transformer.setoutputproperty(outputkeys.encoding, "utf-8");     stringwriter writer = new stringwriter();     transformer.transform(new domsource(document), new streamresult(writer));     writer.tostring();  } 

test class

public class test {      public static void main(string[] args){          document doc = documentbuilderfactory.newinstance().newdocumentbuilder().parse(xmlpath);          //doing process on doc , changing other values           string xmlstring = utils.transformtostring(doc);           // sending xml soap             httppost post = new httppost(endpoint);     post.setentity(new stringentity(xmlstring));     post.setheader(new basicheader("content-type", "text/xml"));                .................      }  } 

xml file

 <?xml version="1.0" encoding="utf-8"?>   <soapenv:envelope ....> <soapenv:header/> <soapenv:body> <test>     <id>佥佬佧佼a£</id>     ..............     .......... </test> ......... 

i getting xmlstring id value : ????a£
want : 佥佬佧佼a£

how can ? want string format of xml.

edit : loading 1 xml, doing changes it, , sending xml soap, setting document httppost.setentity()

thanks, ankit

you can try:

encoding="utf-16" 

instead of

encoding="utf-8" 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -