|
|
@ -16,11 +16,10 @@ import javax.xml.parsers.DocumentBuilderFactory; |
|
|
|
public class FeedParser { |
|
|
|
|
|
|
|
ParserCallback callback; |
|
|
|
NewsItemList newsItemList; |
|
|
|
String inputXML; |
|
|
|
|
|
|
|
interface ParserCallback { |
|
|
|
void onSuccessParsing(NewsItemList newsItemList); |
|
|
|
void onSuccessParsing(); |
|
|
|
void onFailureParsing(); |
|
|
|
} |
|
|
|
|
|
|
@ -29,13 +28,10 @@ public class FeedParser { |
|
|
|
} |
|
|
|
|
|
|
|
FeedParser(String inputXML) { |
|
|
|
newsItemList = new NewsItemList(); |
|
|
|
this.inputXML = inputXML; |
|
|
|
} |
|
|
|
|
|
|
|
void parseXML() { |
|
|
|
|
|
|
|
NewsItemList.Group group = new NewsItemList().new Group(); // <---Remove that
|
|
|
|
try { |
|
|
|
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
|
|
|
// Создается дерево DOM документа из файла
|
|
|
@ -43,17 +39,14 @@ public class FeedParser { |
|
|
|
|
|
|
|
// Получаем корневой элемент
|
|
|
|
Node root = document.getDocumentElement(); |
|
|
|
String exp = root.getTextContent(); // <---Remove that
|
|
|
|
group.set("Node",exp,""); // <---Remove that
|
|
|
|
newsItemList.add(group);// <---Remove that
|
|
|
|
String exp = root.getTextContent(); |
|
|
|
//group.set("Node",exp,"");
|
|
|
|
//newsItemList.add(group);
|
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
group.set("Node2","end",""); // <---Remove that
|
|
|
|
newsItemList.add(group);// <---Remove that
|
|
|
|
group.set("Node3","2end",""); // <---Remove that
|
|
|
|
newsItemList.add(group);// <---Remove that
|
|
|
|
callback.onSuccessParsing(newsItemList); |
|
|
|
|
|
|
|
callback.onSuccessParsing(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|