简体   繁体   中英

XML parsing of some special characters using SAX parser in Android

I made a xml parser using this example (Listing 6. The SAX handler). I have to parse the file which is coming from the server. The file received from server has "ISO-8859-1" encoding.

The problem is that received file from server has some special characters like &, ", ' etc. I know server should send & instead of & , but server will send & only, it cannot replace & to & due to some other problems. I also do inputSource.setEncoding("ISO-8859-1"). I want to parse this file, but parser cannot parse these special characters. What should i do? Any help....

I have another doubt is that "The charset of ISO-8859-1 has these special characters then why parser cannot parse these special characters?"

You can parse as XPL and then run the results through any XML process. XPL is just like XML except that it allows special characters in text elements (this is the reason it exists). The XPL process also generates XML output in the specified encoding (or defaults to UTF-8 if not specified).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM