我目前正在使用简单框架将xml响应映射到Object。 此对象具有另一个Class的ArrayList的Attribute。代码在android上运行。
我的问题是,框架在第63个元素之后以异常结束。
XMLPULLPARSEREXCEPTION: UNTERMINATED ENTITY REF
xml响应的示例:
<assignedUsers>
<user name="1" titel="user1" groupname="group1" ...><user name="2" titel="user2"... >...<user name="n" titel="userN" ...>
</assignedUsers>
响应包含大约100个用户。该文件包含23599个字符。我检查了响应,很好。如果我将列表缩短为63个元素,我的代码就会没有任何问题。有任何建议如何处理?
感谢您的帮助
更新 - 这是stacktrace:
org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:START_TAG <dashboard name='ABC 2012 Character Comparison (Cluster Top 5)'>@12:14965 in java.io.InputStreamReader@a9404f80)
at org.kxml2.io.KXmlParser.readEntity(KXmlParser.java:1203)
at org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1385)
at org.kxml2.io.KXmlParser.parseStartTag(KXmlParser.java:1109)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:369)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
at org.simpleframework.xml.stream.PullReader.read(PullReader.java:105)
at org.simpleframework.xml.stream.PullReader.next(PullReader.java:89)
at org.simpleframework.xml.stream.NodeReader.readElement(NodeReader.java:111)
at org.simpleframework.xml.stream.InputElement.getNext(InputElement.java:216)
at org.simpleframework.xml.core.CompositeList.populate(CompositeList.java:169)
at org.simpleframework.xml.core.CompositeList.read(CompositeList.java:120)
at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623)
at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573)
at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549)
at org.simpleframework.xml.core.Composite.readElement(Composite.java:532)
at org.simpleframework.xml.core.Composite.readElements(Composite.java:445)
at org.simpleframework.xml.core.Composite.access$400(Composite.java:59)
at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383)
at org.simpleframework.xml.core.Composite.read(Composite.java:201)
at org.simpleframework.xml.core.Composite.read(Composite.java:148)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
at org.simpleframework.xml.core.Persister.read(Persister.java:625)
at org.simpleframework.xml.core.Persister.read(Persister.java:606)
at org.simpleframework.xml.core.Persister.read(Persister.java:584)
at org.simpleframework.xml.core.Persister.read(Persister.java:543)
at org.simpleframework.xml.core.Persister.read(Persister.java:521)
at org.simpleframework.xml.core.Persister.read(Persister.java:426)
以下是回复:
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<loggedIn>true</loggedIn>
<errorMessage></errorMessage>
<firstName>Homer Jay</firstName>
<lastName>Simpson</lastName>
<email>abc@def.com</email>
<userId></userId>
<assignedDashboards>
<dashboard name="ABC 2012 Opponent Comparison (Table Top 5)"
guid="d37e8537-16bc-44db-af13-5e12bca509a2" groupName="Global ABC"
groupDescription="" groupExpanded="NO" id="62" dashboardGroupId="10" />
<dashboard name="DEF 2012 Character Comparison (Jerry & Tom)"
guid="3624215a-7d27-406f-a9cb-b25663462aa4" groupName="Global ABC"
groupDescription="" groupExpanded="NO" id="68" dashboardGroupId="10" />
</assignedDashboards>
</response>
这是要映射的类: @root(名称=&#34;响应&#34) public class ResponseDashboardList {
@Element(name="loggedIn")
private String loggedIn;
@Element(name="errorMessage", required = false)
private String errorMessage;
@Element(name="firstName")
private String firstName;
@Element(name="lastName")
private String lastName;
@Element(name="email")
private String email;
@Element(name="userId")
private String userId;
@ElementList (required = false)
private List<Dashboard> assignedDashboards;
解析文件的命令:
ResponseDashboardList responseDashboardList = serializer.read(ResponseDashboardList.class,file);
答案 0 :(得分:0)
很难说没有更多细节,但在最后(37?)元素中查找数据中的&符号。
可能是他们通过非转义,XML解析器会将其解释为实体的开头(有关实体的更多背景,请参阅predefined entities in XML)。