简体   繁体   中英

Escape special characters/Symbols in XML?

while creating a XML using a table in my DB , i got many special characters like registered trademark, trademark, degree, different punctuation, etc (these are present in symbol form , hexadecimal, name code , number code )... . some other words like , °, ...

Also some characters are shown as x99,xEA, etc in my XML.

Is there a library/ API to handle all these while creating XML using JAVA Code. I am using "UTF-8" character encoding for my XML.

Also i cann't clean my DB to have consistent data since it's production data.

一种可能的选择是将您的数据包含在CDATA标记中,这会将数据标记为可能包含标记的字符数据,但不应这样处理。

There is a free command line tool for transforming files with special characters in text to valid XML. It also assures that the file encoding matches what is specified in the declaration.

There is also a Java developer suite that allows you to use the parser to parse such files (called XPL) as an alternative to XML or a pre-process into XML. It uses a StAX-like process called StAX-PL.

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