You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Rickardsson Daniel <da...@wmdata.com> on 2004/11/04 10:41:36 UTC
How to read encoding(processing instruction) from incoming parsed xml?
Hello!
I wonder how it is possible to read the incoming processing instruction (encoding) from an xml-string?!
If you parse an incoming xml-string with the following processing instruction:
<?xml version="1.0" encoding="iso-8859-1"?>
I have not found any way to read the encoding attribut!
I have the following xml:
msg = msg + "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
msg = msg + "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:lm=\"urn:2003:08\">";
msg = msg + "<soap:Header>";
msg = msg + "<lm:messageId mId=\"1234567891\"/>";
msg = msg + "<lm:from systemName=\"persref1\"/>";
msg = msg + "<lm:user uId=\"kalle\" soap:mustUnderstand=\"true\"/>";
msg = msg + "<lm:messageType name=\"response\"/>";
msg = msg + "<lm:from systemName=\"persref2\"/>";
msg = msg + "</soap:Header>";
msg = msg + "<soap:Body>";
msg = msg + "<urn:Adress xmlns:urn=\"urn:cdm:2004:05\" postort=\"Gavle\" postnummer=\"80292\" careOf=\"care of\">";
msg = msg + "<urn:Namn firstName=\"Kalle\"/>";
msg = msg + "</urn:Adress>";
msg = msg + "</soap:Body>";
msg = msg + "</soap:Envelope>";
And I have the following lines of code:
EnvelopeDocument env = EnvelopeDocument.Factory.parse(msg);
String encoding = env.documentProperties().getEncoding();
Why is the encoding parameter null?! Is there any other way to solve the problem?!
Thanks... Daniel.