解析XML.sax.SAXParseException时获取org.xmlGetting异常:元素的内容必须由格式正确的字符数据或标记组成

时间:2022-07-28 16:15:03

I am sending one query in the handler formed from WSDL file, its nothing but to execute a query if we don't have access to databse. the handler has only one xml tag inside which we have to write query which we want to execute then it will query database and return the response in xml format. i am executing a simple select query to get the details of one row. but in the response i am getting the below exception

我在由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();    

can anyone please help me with this exception? where to look for? any modification required? do i need to check the tags in return data ? are those valid basically Child1 tag is designed in such a way that it holds an XML inside it which will go and persist into one column of the table

任何人都可以帮我解决这个例外吗?在哪里寻找?需要修改吗?我需要检查返回数据中的标签吗?是那些有效的基本上Child1标签是这样设计的,它在其中包含一个XML,它将继续存在于表的一列中

1 个解决方案

#1


0  

Your XML is invalid

您的XML无效

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

You cannot have space in XML element name. Your xml element name Child 1 is having a space.

您不能在XML元素名称中包含空格。您的xml元素名称Child 1有空格。

XML elements name must follow these naming rules.....

XML元素名称必须遵循这些命名规则.....

  • Names can contain letters, numbers, and other characters
  • 名称可以包含字母,数字和其他字符

  • Names cannot start with a number or punctuation character
  • 名称不能以数字或标点字符开头

  • Names cannot start with the letters xml (or XML, or Xml, etc)
  • 名称不能以字母xml(或XML或Xml等)开头

  • Names cannot contain spaces
  • 名称不能包含空格

#1


0  

Your XML is invalid

您的XML无效

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

You cannot have space in XML element name. Your xml element name Child 1 is having a space.

您不能在XML元素名称中包含空格。您的xml元素名称Child 1有空格。

XML elements name must follow these naming rules.....

XML元素名称必须遵循这些命名规则.....

  • Names can contain letters, numbers, and other characters
  • 名称可以包含字母,数字和其他字符

  • Names cannot start with a number or punctuation character
  • 名称不能以数字或标点字符开头

  • Names cannot start with the letters xml (or XML, or Xml, etc)
  • 名称不能以字母xml(或XML或Xml等)开头

  • Names cannot contain spaces
  • 名称不能包含空格