如何解决ExpatParser $ parseException

时间:2012-11-06 13:25:09

标签: java

我从我的网络网络服务

获得以下结果
<?xml version="1.0" encoding="utf-8" ?> 
- <DataTable xmlns="http://www.mkttech.in/">
- <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="RecordSet" msdata:UseCurrentLocale="true">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="RecordSet">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="USERNAME" minOccurs="0">
- <xs:simpleType>
- <xs:restriction base="xs:string">
  <xs:maxLength value="51" /> 
  </xs:restriction>
  </xs:simpleType>
  </xs:element>
  <xs:element name="PWD_EXPIRY" type="xs:int" minOccurs="0" /> 
  <xs:element name="FLDPWDMINLENGTH" type="xs:short" minOccurs="0" /> 
  <xs:element name="FLDPWDMAXLENGTH" type="xs:short" minOccurs="0" /> 
  <xs:element name="FLDMAXATTEMPT" type="xs:short" minOccurs="0" /> 
- <xs:element name="LOG_REASON" minOccurs="0">
- <xs:simpleType>
- <xs:restriction base="xs:string">
  <xs:maxLength value="200" /> 
  </xs:restriction>
  </xs:simpleType>
  </xs:element>
- <xs:element name="EXCH_SEG" msdata:ReadOnly="true" minOccurs="0">
- <xs:simpleType>
- <xs:restriction base="xs:string">
  <xs:maxLength value="51" /> 
  </xs:restriction>
  </xs:simpleType>
  </xs:element>
- <xs:element name="SEGMENTDESC" minOccurs="0">
- <xs:simpleType>
- <xs:restriction base="xs:string">
  <xs:maxLength value="100" /> 
  </xs:restriction>
  </xs:simpleType>
  </xs:element>
- <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
- <DocumentElement xmlns="">
- <RecordSet diffgr:id="RecordSet1" msdata:rowOrder="0">
  <USERNAME /> 
  <PWD_EXPIRY>0</PWD_EXPIRY> 
  <FLDPWDMINLENGTH>2</FLDPWDMINLENGTH> 
  <FLDPWDMAXLENGTH>8</FLDPWDMAXLENGTH> 
  <FLDMAXATTEMPT>100</FLDMAXATTEMPT> 
  <LOG_REASON>INVALID PASSWORD...</LOG_REASON> 
  <EXCH_SEG>NSE-CAPITAL</EXCH_SEG> 
  <SEGMENTDESC>NSE Capital Market</SEGMENTDESC> 
  </RecordSet>
  </DocumentElement>
  </diffgr:diffgram>
  </DataTable>

我正在使用SoapObject来接收此响应。 接下来我使用xmlpullparser解析它。 我遵循以下Tutorial

但是我在执行nextTag()时遇到异常

org.xmlpull.v1.XmlPullParserException:解析文档时出错。 (位置:第-1行,第-1列)由以下原因引起:org.apache.harmony.xml.ExpatParser $ ParseException:第1行第7列:格式不正确(无效令牌)

我是android和java的新手。我真的需要帮助。 提前谢谢!

1 个答案:

答案 0 :(得分:2)

<?xml version="1.0"...之前应该没有空格。请查看此在线应用XML/XSD Validation