Respected everyone, I want to read XML files, for this I used the SaCapreser and default handler for the method characters (four [] f , Int light, int length) but it gives output with some extra characters like '[13] instead of']. Someone told me that if I read that string in UTF-8 format then it will add all the extra characters Will remove. Is it true that I have to read it in UTF-8 format, if so, how can I read it Thanks (Vikram Kadam)
I use it to parse SAXparser:
url = new URL (urluptures); SAXParserFactory spf = SAXParserFactory.newInstance (); // Here we receive our SAX Parser SAXParser SP = spf.newSAXParser (); // We fuse it in the XML reader XMLReader xr = sp.getXMLReader (); Default handler handlercontact = new DefaultHandler (); // We give it a handler to manage various methods xr.setContentHandler (handler contact); // And finally we open the stream in the URL InputStream oS = url.openstream (); // and it's xr pars (new input source (new inputstream reader) (OS, charset forum ("UTF-8")); // Handler Results = Contact.getEntries () to recover the list of contacts created by handler; // Do not forget to close the resource oS.close ();
I did not have any problems until the initial file that you are parsing is properly encoded in UTF-8. Check what this is, because sometimes, when you use the default configuration of your computer, the default UTF-8 is not ANSI or ISO-8859-1
Comments
Post a Comment