我正在尝试使用XMLView显示小html。这是html
<?xml version="1.0" encoding="windows-1252"?>
<doc><body><p uiid="headline"> Election Result</b></p><p>Ward -- W1001<br>
</p><p>Votes For -- ABP,200<br> -- A,100<br></p><carousel> <img src="http://res.cloudinary.com/okwui/image/upload/v1545561341/pukuxkn2pgmgbcplqgi8.png"/><br>
<img src="http://res.cloudinary.com/okwui/image/upload/v1545561342/zkwfawmolbvta3lfd2ld.png"/><br></carousel><p>
Additional Notes -- <br></p><p>Election -- Presidential2019<br></p><p>Date of Election -- Sun Dec 23 11:35:14 WAT 2018<br></p><p>Booth -- B001<br></p>
<p>Constituency -- C001<br></p><p>State -- Abia<br></p> </body></doc
我不断收到此错误
java.lang.NullPointerException
at com.codename1.xml.Element.iterator(Element.java:767)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:66)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:68)
at com.codename1.components.xmlview.ParagraphView.getText(ParagraphView.java:75)
at com.codename1.components.xmlview.ParagraphView.createView(ParagraphView.java:50)
at com.codename1.components.xmlview.XMLView.createView(XMLView.java:377)
at com.codename1.components.xmlview.XMLView.setXML(XMLView.java:356)
at com.codename1.components.xmlview.XMLView.setXML(XMLView.java:302)
很明显,XML文件有问题,但是我无法查明。请帮助。
答案 0 :(得分:1)
您需要遵循XMLView project中提到的语法,例如<br>
是无效的XML。我不确定身体是否必要:
请参见https://github.com/shannah/cn1-xmlview/blob/master/src/SampleNewsFeed.xml