gpt4 book ai didi

java - Errorr无效的 XML 字符 (Unicode : 0xb) was found in the element content of the document while parsing xml with DOM parser

转载 作者:行者123 更新时间:2023-11-29 05:27:54 24 4
gpt4 key购买 nike

ErrorrAn invalid XML character (Unicode: 0xb) was found in the element content of the document.

当我尝试使用 dom 解析器解析 xml 数据时出现此错误?

这是什么原因?

我该如何解决这个问题?

编辑这是 XML 文件片段

<CIRS><CIR applicantId="131906564" loanId="126907905" applicantRefId="TSFI012095G1" fan="TSFI012095"><REQUESTDATA><NAME>D DUNSTON JOSEPH WILFRED</NAME><DOB>31-07-1966</DOB><GENDER>Male</GENDER><ID><TYPE>PASSPORT NUMBER</TYPE><VALUE>H3359853</VALUE></ID><ID><TYPE>DRIVER'S LICENSE NUMBER</TYPE><VALUE>R/TN/69/005545/2005</VALUE></ID><PHONE>95412563#25,23778#34,87976#54</PHONE>

我猜问题出在电话号码标签 <PHONE>95412563#25,23778#34,87976#54</PHONE>

最佳答案

每当在 xml 中输入无效的 xml 字符时,它就会给出这样的错误。当你在 Notepad++ 中打开它时,它看起来像 VT、SOH、FF。这些是无效的 xml 字符。我正在使用 xml 1.0 版,并在将文本数据输入数据库之前使用以下模式验证文本数据:

Pattern p = Pattern.compile("[^\\u0009\\u000A\\u000D\u0020-\\uD7FF\\uE000-\\uFFFD\\u10000-\\u10FFF]+");
retunContent = p.matcher(retunContent).replaceAll("");

它将确保不会在 xml 中输入无效的特殊字符。

关于java - Errorr无效的 XML 字符 (Unicode : 0xb) was found in the element content of the document while parsing xml with DOM parser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22072872/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com