* If theres a problem with the parsing.
* @see SearchIQ
*/
public IQ parseIQ(XmlPullParser parser) throws Exception {
SearchIQ result = new SearchIQ();
DefaultPacketExtension item = null;
String currentTag = null;
String key = null;
int event = parser.getEventType();
/*
* while (!(event==XmlPullParser.END_TAG &&
* parser.getName().equals("query"))){
* if(event==XmlPullParser.START_TAG){ if(item==null &&
* parser.getName().equals("item") && (!parser.isEmptyElementTag())){
* item=new DefaultPacketExtension("item","");
* key=parser.getAttributeValue(0); currentTag=null; } else{
* currentTag=parser.getName(); if(item==null &&
* parser.isEmptyElementTag()){ if(!currentTag.equals("instructions")){
* result.addField(currentTag); currentTag=null; } } } }
* if(event==XmlPullParser.TEXT && currentTag!=null){ if(item!=null){
* item.setValue(currentTag,parser.getText()); } else{
* if(!currentTag.equals("instructions")){
* result.setField(currentTag,parser.getText()); } else{
* result.setInstructions(parser.getText()); } } currentTag=null; }
* if(event==XmlPullParser.END_TAG && parser.getName().equals("item") &&
* item!=null){ result.addItem(key,item); item=null; }
* event=parser.next(); }
*/
while (!(event == XmlPullParser.END_TAG && parser.getName().equals(
"query"))) {
if (event == XmlPullParser.START_TAG) {
if (item == null && parser.getName().equals("item")
&& (!parser.isEmptyElementTag())) {
item = new DefaultPacketExtension("item", "");
key = parser.getAttributeValue(0);
currentTag = null;
} else {
currentTag = parser.getName();
if (item == null && parser.isEmptyElementTag()) {
if (!currentTag.equals("instructions")) {
result.addField(currentTag);
currentTag = null;
}
}
}
if (currentTag != null && currentTag.equals("x")) {
result.addExtension(PacketParserUtils.parsePacketExtension(
parser.getName(), parser.getNamespace(), parser));
}
}
if (event == XmlPullParser.TEXT && currentTag != null) {
if (item != null) {
item.setValue(currentTag, parser.getText());
} else {
if (!currentTag.equals("instructions")) {
result.setField(currentTag, parser.getText());
} else {
result.setInstructions(parser.getText());