Hello,
I'm also very interesting about "how to parse a xml string", but I'm a
newbie both with java and xerces (what a challenge!!!)
May you please write the code sample to change the initial code produce by
Gude Reshma and then show me how to < use the "getBytes(String)" > or <use
a StringReader instead>
Here is the initial code :
//######################################
public Document parseString(String str)
{
//System.out.println("in parse string :: string got is "+str);
Document doc = null;
try
{
byte[] byte_array_of_string = str.getBytes();
InputStream istr = new ByteArrayInputStream(byte_array_of_string);
InputSource is = new InputSource(istr);
DOMParser dom_parser = new DOMParser();
dom_parser.parse(is);
doc = dom_parser.getDocument();
}
catch(Exception e)
{
}
return(doc);
}
//##################################################"
Thanks you very much
Jean-Charles Dufour
-----Message d'origine-----
De : Andy Clark [mailto:[EMAIL PROTECTED]
Envoye : jeudi 11 avril 2002 15:49
A : [EMAIL PROTECTED]
Objet : Re: HOW TO PARSE A XML STRING
Gude Reshma wrote:
> byte[] byte_array_of_string = str.getBytes();
Never use the zero parameter "getBytes" method because it will
return the bytes in the system's default locale, which may not
be able to encode the characters in your file.
Instead, use the "getBytes(String)" variety so that you can
specify the encoding of the bytes that are returned. (Also
remember that you should match the encoding with what is
declared in the XMLDecl line -- <?xml version='1.0'
encoding='...'?>.)
Or better yet, use a StringReader instead. Then you don't have
to worry about matching the encoding specified in the XMLDecl.
--
Andy Clark * [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]