Web Services 解析XML时出现异常,SAXParseException:元素的内容必须由格式正确的字符数据或标记组成

xkftehaa  于 2022-11-15  发布在  其他
关注(0)|答案(1)|浏览(152)

我将在WSDL文件形成的处理程序中发送一个查询,如果我们没有访问数据库的权限,就只能执行查询。处理程序只有一个xml标记,我们必须在其中写入要执行的查询,然后它将查询数据库并以xml格式返回响应。我正在执行一个简单的选择查询,以获取一行的详细信息。但是在响应中我得到了下面的异常

org.xml.sax.SAXParseException:The content of elements must consist of well-formed character data or markup.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)

proper return response XML should be
<row>    
 <Vendor>
      <Number>
         <CountryCode>1</CountryCode>
         <AreaCode>23</AreaCode>
         <SubNumber>456</SubNumber>
      </Number>
 </Vendor>
</row>

in this <SubNumber> tag is giving error,
i am not aware of value inside this tag in database.

i followed the stack trace and piece of code which is throwing the exception is:
   DOMParser parser = new DOMParser();

有没有人可以帮助我解决这个异常?在哪里查找?需要进行任何修改?我需要检查返回数据中的标记吗?这些标记基本上有效吗?Child1标记的设计方式是,它在内部保存一个XML,该XML将进入并持久保存到表的一列中

jljoyd4f

jljoyd4f1#

您的XML无效

row-->Parent-->Child-->Child 1

XML元素名称中不能有空格。您的XML元素名称Child 1中有空格。
XML元素名称必须跟在这些naming rules.....后面

  • 名称可以包含字母、数字和其他字符
  • 名称不能以数字或标点符号字符开头
  • 名称不能以字母xml(或XML、Xml等)开头
  • 名称不能包含空格

相关问题