`
jaychang
  • 浏览: 734876 次
  • 性别: Icon_minigender_1
  • 来自: 嘉兴
社区版块
存档分类
最新评论

XML中对特殊字符的处理

    博客分类:
  • XML
阅读更多
                                                str = str.replaceAll("‘", "‘");
			str = str.replaceAll("’", "‘");
			str = str.replaceAll("“", "”");
			str = str.replaceAll("”", "”");
			str = str.replaceAll("—", "—");		
			str = str.replaceAll("¢","¢");
			str = str.replaceAll("£","£");
			str = str.replaceAll("¤","¤");
			str = str.replaceAll("¥","¥");
			str = str.replaceAll("¦","|");
			str = str.replaceAll("§","§");
			str = str.replaceAll("¨","¨");
			str = str.replaceAll("ª","a");
			str = str.replaceAll("­","-");
			str = str.replaceAll("¯","ˉ");
			str = str.replaceAll("°","°");
			str = str.replaceAll("±","±");
			str = str.replaceAll("µ","μ");
			str = str.replaceAll("·","·");
			str = str.replaceAll("¹","1");
			str = str.replaceAll("º","o");
			str = str.replaceAll("×","×");
			str = str.replaceAll("÷","÷");
			str = str.replaceAll("…","…");
			str = str.replaceAll("‾"," ̄");
			str = str.replaceAll("←","←");
			str = str.replaceAll("↑","↑");
			str = str.replaceAll("→","→");
			str = str.replaceAll("↓","↓");
			str = str.replaceAll("∏","∏");
			str = str.replaceAll("∑","∑");
			str = str.replaceAll("√","√");
			str = str.replaceAll("∝","∝");
			str = str.replaceAll("∞","∞");
			str = str.replaceAll("∠","∠");
			str = str.replaceAll("∧","∧");
			str = str.replaceAll("∨","∨");
			str = str.replaceAll("∩","∩");
			str = str.replaceAll("∪","∪");
			str = str.replaceAll("∫","∫");
			str = str.replaceAll("∴","∴");
			str = str.replaceAll("∼","~");
			str = str.replaceAll("≈","≈");
			str = str.replaceAll("≠","≠");
			str = str.replaceAll("≡","≡");
			str = str.replaceAll("≤","≤");
			str = str.replaceAll("≥","≥");
			str = str.replaceAll("⊕","?");
			str = str.replaceAll("⊥","⊥");
			str = str.replaceAll("–","–");
			str = str.replaceAll("—","—");
			str = str.replaceAll("‰","‰");
			str = str.replaceAll("€","?");
			str = str.replaceAll("À","à");
			str = str.replaceAll("Á","á");
			str = str.replaceAll("È","è");
			str = str.replaceAll("É","é");
			str = str.replaceAll("Ê","ê");
			str = str.replaceAll("Ì","ì");
			str = str.replaceAll("Í","í");
			str = str.replaceAll("Ð","D");
			str = str.replaceAll("Ò","ò");
			str = str.replaceAll("Ó","ó");
			str = str.replaceAll("Ù","ù");
			str = str.replaceAll("Ú","ú");
			str = str.replaceAll("Ü","ü");
			str = str.replaceAll("Ý","Y");
			str = str.replaceAll("Þ","T");
			str = str.replaceAll("à","à");
			str = str.replaceAll("á","á");
			str = str.replaceAll("â","a");
			str = str.replaceAll("è","è");
			str = str.replaceAll("é","é");
			str = str.replaceAll("ê","ê");
			str = str.replaceAll("ì","ì");
			str = str.replaceAll("í","í");
			str = str.replaceAll("ð","e");
			str = str.replaceAll("ò","ò");
			str = str.replaceAll("ó","ó");
			str = str.replaceAll("ù","ù");
			str = str.replaceAll("ú","ú");
			str = str.replaceAll("ü","ü");
			str = str.replaceAll("ý","y");
			str = str.replaceAll("þ","t");
			str = str.replaceAll("Α","Α");
			str = str.replaceAll("Β","Β");
			str = str.replaceAll("Γ","Γ");
			str = str.replaceAll("Δ","Δ");
			str = str.replaceAll("Ε","Ε");
			str = str.replaceAll("Ζ","Ζ");
			str = str.replaceAll("Η","Η");
			str = str.replaceAll("Θ","Θ");
			str = str.replaceAll("Ι","Ι");
			str = str.replaceAll("Κ","Κ");
			str = str.replaceAll("Λ","Λ");
			str = str.replaceAll("Μ","Μ");
			str = str.replaceAll("Ν","Ν");
			str = str.replaceAll("Ξ","Ξ");
			str = str.replaceAll("Ο","Ο");
			str = str.replaceAll("Π","Π");
			str = str.replaceAll("Ρ","Ρ");
			str = str.replaceAll("Σ","Σ");
			str = str.replaceAll("Τ","Τ");
			str = str.replaceAll("Υ","Υ");
			str = str.replaceAll("Φ","Φ");
			str = str.replaceAll("Χ","Χ");
			str = str.replaceAll("Ψ","Ψ");
			str = str.replaceAll("Ω","Ω");
			str = str.replaceAll("α","α");
			str = str.replaceAll("β","β");
			str = str.replaceAll("γ","γ");
			str = str.replaceAll("δ","δ");
			str = str.replaceAll("ε","ε");
			str = str.replaceAll("ζ","ζ");
			str = str.replaceAll("η","η");
			str = str.replaceAll("θ","θ");
			str = str.replaceAll("ι","ι");
			str = str.replaceAll("κ","κ");
			str = str.replaceAll("λ","λ");
			str = str.replaceAll("μ","μ");
			str = str.replaceAll("ν","ν");
			str = str.replaceAll("ξ","ξ");
			str = str.replaceAll("ο","ο");
			str = str.replaceAll("π","π");
			str = str.replaceAll("ρ","ρ");
			str = str.replaceAll("σ","σ");
			str = str.replaceAll("τ","τ");
			str = str.replaceAll("υ","υ");
			str = str.replaceAll("φ","φ");
			str = str.replaceAll("χ","χ");
			str = str.replaceAll("ψ","ψ");
			str = str.replaceAll("ω","ω");			
			str = str.replaceAll("´","?");
			str = str.replaceAll("©","?");
			str = str.replaceAll("µ","?");
			str = str.replaceAll("®","?");
			str = str.replaceAll("°","°");
			str = str.replaceAll("¡","?");
			str = str.replaceAll("»","?");
			str = str.replaceAll("¦","?");
			str = str.replaceAll("÷","÷");
			str = str.replaceAll("¿","?");
			str = str.replaceAll("¬","?");
			str = str.replaceAll("§","§");
			str = str.replaceAll("•","?");
			str = str.replaceAll("½","?");
			str = str.replaceAll("«","?");
			str = str.replaceAll("¶","?");
			str = str.replaceAll("¨","¨");
			str = str.replaceAll("¸","?");
			str = str.replaceAll("¼","?");
			str = str.replaceAll("±","±");
			str = str.replaceAll("×","×");
			str = str.replaceAll("¢","?");
			str = str.replaceAll("¾","?");
			str = str.replaceAll("¯","?");
			str = str.replaceAll("™","?");
			str = str.replaceAll("€","?");
			str = str.replaceAll("£","?");
			str = str.replaceAll("¥","?");
			str = str.replaceAll("„","?");
			str = str.replaceAll("…","…");
			str = str.replaceAll("·","·");
			str = str.replaceAll("›","?");
			str = str.replaceAll("ª","?");
			str = str.replaceAll("ˆ","?");
			str = str.replaceAll("º","?");
			str = str.replaceAll("†","?");
			str = str.replaceAll("‹","?");
			str = str.replaceAll("‚","?");
			str = str.replaceAll("‰","‰");
			str = str.replaceAll("­","?");
			str = str.replaceAll("˜","?");
			str = str.replaceAll("≈","≈");
			str = str.replaceAll("⁄","?");
			str = str.replaceAll("←","←");
			str = str.replaceAll("∂","?");
			str = str.replaceAll("♠","?");
			str = str.replaceAll("∩","∩");
			str = str.replaceAll("≥","≥");
			str = str.replaceAll("≤","≤");
			str = str.replaceAll("∑","∑");
			str = str.replaceAll("♣","?");
			str = str.replaceAll("⇔","?");
			str = str.replaceAll("◊","?");
			str = str.replaceAll("′","′");
			str = str.replaceAll("↑","↑");
			str = str.replaceAll("↓","↓");
			str = str.replaceAll("♥","?");
			str = str.replaceAll("−","?");
			str = str.replaceAll("∏","∏");
			str = str.replaceAll("‍","?");
			str = str.replaceAll("♦","?");
			str = str.replaceAll("∞","∞");
			str = str.replaceAll("≠","≠");
			str = str.replaceAll("√","√");
			str = str.replaceAll("‌","?");
			str = str.replaceAll("≡","≡");
			str = str.replaceAll("∫","∫");
			str = str.replaceAll("‾","?");
			str = str.replaceAll("→","→");
			str = str.replaceAll("α","α");
			str = str.replaceAll("η","η");
			str = str.replaceAll("μ","μ");
			str = str.replaceAll("π","π");
			str = str.replaceAll("θ","θ");
			str = str.replaceAll("β","β");
			str = str.replaceAll("γ","γ");
			str = str.replaceAll("ν","ν");
			str = str.replaceAll("ψ","ψ");
			str = str.replaceAll("υ","υ");
			str = str.replaceAll("χ","χ");
			str = str.replaceAll("ι","ι");
			str = str.replaceAll("ω","ω");
			str = str.replaceAll("ρ","ρ");
			str = str.replaceAll("ξ","ξ");
			str = str.replaceAll("δ","δ");
			str = str.replaceAll("κ","κ");
			str = str.replaceAll("ο","ο");
			str = str.replaceAll("σ","σ");
			str = str.replaceAll("ζ","ζ");
			str = str.replaceAll("ε","ε");
			str = str.replaceAll("λ","λ");
			str = str.replaceAll("φ","φ");
			str = str.replaceAll("τ","τ");
			str = str.replaceAll("Α","Α");
			str = str.replaceAll("Η","Η");
			str = str.replaceAll("Μ","Μ");
			str = str.replaceAll("Π","Π");
			str = str.replaceAll("Θ","Θ");
			str = str.replaceAll("Β","Β");
			str = str.replaceAll("Γ","Γ");
			str = str.replaceAll("Ν","Ν");
			str = str.replaceAll("Ψ","Ψ");
			str = str.replaceAll("Υ","Υ");
			str = str.replaceAll("Χ","Χ");
			str = str.replaceAll("Ι","Ι");
			str = str.replaceAll("Ω","Ω");
			str = str.replaceAll("Ρ","Ρ");
			str = str.replaceAll("Ξ","Ξ");
			str = str.replaceAll("Δ","Δ");
			str = str.replaceAll("Κ","Κ");
			str = str.replaceAll("Ο","Ο");
			str = str.replaceAll("Σ","Σ");
			str = str.replaceAll("Ζ","Ζ");
			str = str.replaceAll("Ε","Ε");
			str = str.replaceAll("Λ","Λ");
			str = str.replaceAll("Φ","Φ");
			str = str.replaceAll("Τ","Τ");
			str = str.replaceAll("ς","?");

 

分享到:
评论

相关推荐

    解析XML特殊字符方法

    XML(eXtensible Markup ...总结来说,理解并正确处理XML特殊字符是XML编程中的基础,也是保证数据正确传输和解析的关键。不论是手动编写XML文档,还是通过编程语言操作XML,都应确保特殊字符被适当地转义或编码。

    xml中的特殊字符替换

    在XML(可扩展标记语言)中,特殊字符的处理是一项重要的技术细节,它直接关系到文档的正确解析和展示。由于XML是一种用于标记文本的元语言,它使用一系列的规则来定义数据结构和数据类型,因此,对于XML文档中可能...

    mybatis xml中特殊字符处理及特殊符号

    总结来说,处理MyBatis XML中的特殊字符,可以通过转义特殊字符或使用CDATA区来确保XML的正确解析。选择哪种方法取决于个人喜好和代码的可读性。确保正确处理这些特殊字符是避免MyBatis XML配置文件出错的关键步骤。...

    xml转javaBean,javaBean转xml,xml标签大小写问题,以及对xml特殊符号的处理

    CDATA(Character Data)是XML中的一种特殊语法,用于表示一段纯文本,其中的XML特殊字符(如", ">", "&")不需要转义。在XML中,可以使用`<![CDATA[ ... ]]>`来创建CDATA段。当处理包含大量特殊字符的数据时,使用...

    SQL Server查询中的特殊字符处理(C#代码)

    在IT领域,尤其是在数据库操作与编程中,对特殊字符的处理是至关重要的。特殊字符,如方括号、单引号、百分号、下划线和脱字号等,在SQL语句中有特定的意义,若不正确处理,可能会导致SQL语法错误或注入攻击。本文将...

    Mybatis在Mapper.xml文件中的转义字符处理方式.pdf

    然而,在XML中直接使用一些特殊字符,比如大于(>)、小于(<)、等于(=)、单引号(')和双引号(")等,可能会导致XML解析错误,因为这些字符在XML文档中有特定的含义。为了解决这个问题,Mybatis提供了一些处理...

    ibatis sql语句对条件中特殊字符% # 处理

    ### ibatis SQL语句对条件中特殊字符% # 处理 在开发过程中,经常会遇到SQL查询时需要处理字符串中的特殊字符的情况。特别是在使用类似`LIKE`这样的操作符时,如果用户输入的数据中含有`%`、`_`或`#`等特殊字符,...

    C# XML字符串包含特殊字符的处理转换方法小结

    在C#中,处理XML字符串时,由于XML的语法规则,某些特殊字符不能直接出现在XML文档中,否则会导致解析错误。这些特殊字符包括小于号 `、大于号 `>`、和与号 `&`。此外,对于XML属性值,单引号 `'` 和双引号 `"` 也...

    xml 的特殊字符的处理方法

    ### XML特殊字符转义 1. `转义为 `<` 2. `>` 转义为 `>` 3. `&` 转义为 `&` 4. `'` 转义为 `'` 5. `"` 转义为 `"` 例如,如果你的XML数据中包含字符串 `"It's a <good> day!"`,你应该将其...

    Android xml转义字符

    在Android开发过程中,经常会遇到需要在`res/values/strings.xml`文件中使用特殊字符的情况。由于XML是一种标记语言,它对某些字符有特定的规定,如果直接将这些特殊字符写入XML文件,则可能会导致解析错误或出现非...

    iOS特殊字符处理

    在iOS开发中,特殊字符处理是一项关键任务,尤其是在处理用户输入、存储数据或者网络通信时。Foundation框架和CoreFoundation框架提供了强大的支持来处理这些字符,确保数据的安全性和一致性。下面我们将详细探讨这...

    HTML和XML中的转义字符

    除了以上提到的基本转义字符之外,HTML还支持广泛的特殊字符实体,如数学符号、希腊字母等,这些可以通过Unicode编码来引用。例如,`α` 表示希腊字母α。 #### 三、HTML转义字符使用要点 1. **转义字符必须...

    Mybatis自定义拦截器,对模糊查询传值的特殊字符统一进行转义处理的代码

    特殊字符(\,_,%)转义工具类 MyQueryInterceptor.java: Mybatis自定义拦截器 注意:该拦截器只支持QueryWrapper的like方法,serviceImpl层传全角模糊查询(%%) mapper或xml层的全角模糊查询(%*%)和半角模糊查询(%*或*%)

    js的XML解析器 可以解析XMl文件和XML字符串

    - **特殊字符**:XML文档中可能存在特殊字符,如`、`>`、`&`等,这些在XML中具有特殊含义,需要正确转义。如果未正确处理,可能导致解析错误。 - **浏览器兼容性**:描述中提到的谷歌浏览器的XML解析问题可能是指...

    xml和web特殊字符

    - 在Python中,处理XML和HTML文件时,还可以使用`xml.dom.minidom`库或第三方库如`lxml`,它们提供了DOM(文档对象模型)和XMLParser等方法,自动处理特殊字符的转义和解码,使解析更加方便。 综上所述,理解并...

    彻底根治Spring @ResponseBody JavaScript HTML特殊字符

    在开发Web应用时,我们经常会遇到一个问题:当使用Spring MVC的`@ResponseBody`注解将后端处理结果直接转化为HTTP响应体时,如果这个结果中包含HTML特殊字符,如尖角号、引号、按位与符号等,浏览器可能会误解析,...

    C++ xml文件处理介绍

    综上所述,在.NET框架的C++环境中处理XML文件时,需要掌握XML的基本结构和概念,了解.NET平台提供的XML处理方式及其优势,熟练运用框架中的XML相关命名空间,以实现对XML文件的有效编程和数据处理。

    map/list集合转化成xml字符串 xml字符串转化成map/list集合

    在Java编程中,数据结构与XML(eXtensible Markup Language)之间的转换是常见的操作,尤其是在处理数据交换或存储时。...在进行这样的转换时,确保处理好异常、空值和特殊字符,以确保数据的完整性和安全性。

    使用C++处理XML

    为了处理XML中的中文字符,确保你的XML文档编码声明正确,通常是UTF-8,例如`<?xml version="1.0" encoding="UTF-8"?>`。同时,确保你的源代码文件也是UTF-8编码,这样编译器才能正确识别和处理中文字符。 总的来说...

Global site tag (gtag.js) - Google Analytics