You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
package ru.defend.defdevteam.tstu;
|
|
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Node;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
|
|
import javax.xml.parsers.DocumentBuilder;
|
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
|
|
/**
|
|
* Created by thedefend on 29.11.16.
|
|
*/
|
|
|
|
public class FeedParser {
|
|
|
|
ParserCallback callback;
|
|
String inputXML;
|
|
|
|
interface ParserCallback {
|
|
void onSuccessParsing();
|
|
void onFailureParsing();
|
|
}
|
|
|
|
void registerCallback(ParserCallback callback) {
|
|
this.callback = callback;
|
|
}
|
|
|
|
FeedParser(String inputXML) {
|
|
this.inputXML = inputXML;
|
|
}
|
|
|
|
void parseXML() {
|
|
try {
|
|
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
|
// Создается дерево DOM документа из файла
|
|
Document document = documentBuilder.parse(inputXML);
|
|
|
|
// Получаем корневой элемент
|
|
Node root = document.getDocumentElement();
|
|
String exp = root.getTextContent();
|
|
//group.set("Node",exp,"");
|
|
//newsItemList.add(group);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
callback.onSuccessParsing();
|
|
}
|
|
|
|
}
|
|
|