Node rootNode = null;
Node currNode = null;
try {
InputStreamReader inReader = new InputStreamReader(inStream);
KXmlParser xpp = new KXmlParser();
xpp.setInput(inReader);
int eventType = xpp.getEventType();
while (eventType != org.xmlpull.v1.XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case org.xmlpull.v1.XmlPullParser.START_TAG:
{
Node node = new Node();
String nodeName = xpp.getName();
node.setName(nodeName);
int attrsLen = xpp.getAttributeCount();
for (int n=0; n<attrsLen; n++) {
String attrName = xpp.getAttributeName(n);
String attrValue = xpp.getAttributeValue(n);
node.setAttribute(attrName, attrValue);
}
if (currNode != null)
currNode.addNode(node);
currNode = node;
if (rootNode == null)
rootNode = node;
}
break;
case org.xmlpull.v1.XmlPullParser.TEXT:
{
String value = xpp.getText();
if (currNode != null)
currNode.setValue(value);
}
break;
case org.xmlpull.v1.XmlPullParser.END_TAG:
{
currNode = currNode.getParentNode();
}
break;
}
eventType = xpp.next();
}
}
catch (Exception e) {
throw new ParserException(e);
}