XML 元素过多
XML with too many Elements
我目前正在使用简单框架将 xml 响应映射到对象。
此对象具有另一个 Class 的 ArrayList 的属性。 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 个元素,我的代码结束时不会出现任何问题。有什么处理方法的建议吗?
谢谢你的帮助
更新 - 这是堆栈跟踪:
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.access0(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>
这是要映射的class:
@Root(名字="response")
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, 文件);
很难说没有更多细节,但在最后(37 个?)元素中查找数据中的 & 符号。
可能是它们未转义,XML 解析器会将其解释为实体的开始(有关实体的更多背景信息,请参阅 predefined entities in XML)。
我目前正在使用简单框架将 xml 响应映射到对象。 此对象具有另一个 Class 的 ArrayList 的属性。 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 个元素,我的代码结束时不会出现任何问题。有什么处理方法的建议吗?
谢谢你的帮助
更新 - 这是堆栈跟踪:
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.access0(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>
这是要映射的class: @Root(名字="response") 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, 文件);
很难说没有更多细节,但在最后(37 个?)元素中查找数据中的 & 符号。
可能是它们未转义,XML 解析器会将其解释为实体的开始(有关实体的更多背景信息,请参阅 predefined entities in XML)。