fixed possible npe

This commit is contained in:
Daniel Gultsch 2014-05-14 18:39:59 +02:00
parent f4eebd091c
commit 08a26d2772
1 changed files with 3 additions and 4 deletions

View File

@ -85,10 +85,8 @@ public class XmlReader {
public Element readElement(Tag currentTag) throws XmlPullParserException, IOException { public Element readElement(Tag currentTag) throws XmlPullParserException, IOException {
Element element = new Element(currentTag.getName()); Element element = new Element(currentTag.getName());
//Log.d(LOGTAG,"trying to read element "+element.getName());
element.setAttributes(currentTag.getAttributes()); element.setAttributes(currentTag.getAttributes());
Tag nextTag = this.readTag(); Tag nextTag = this.readTag();
//Log.d(LOGTAG,"next Tag is: "+nextTag.toString());
if(nextTag.isNo()) { if(nextTag.isNo()) {
element.setContent(nextTag.getName()); element.setContent(nextTag.getName());
nextTag = this.readTag(); nextTag = this.readTag();
@ -96,15 +94,16 @@ public class XmlReader {
if (nextTag == null) { if (nextTag == null) {
throw new IOException("unterupted mid tag"); throw new IOException("unterupted mid tag");
} }
//Log.d(LOGTAG,"reading till the end of "+element.getName());
while(!nextTag.isEnd(element.getName())) { while(!nextTag.isEnd(element.getName())) {
if (!nextTag.isNo()) { if (!nextTag.isNo()) {
Element child = this.readElement(nextTag); Element child = this.readElement(nextTag);
element.addChild(child); element.addChild(child);
} }
nextTag = this.readTag(); nextTag = this.readTag();
if (nextTag == null) {
throw new IOException("unterupted mid tag");
}
} }
//Log.d(LOGTAG,"return with element"+element);
return element; return element;
} }
} }