#include "docsanswerparser.h"
#include "docsupdater.h"

DocsAnswerParser::DocsAnswerParser(QObject *parent) : QObject(parent)
{

}

QByteArray DocsAnswerParser::listSubProc(QList<SubProc> list, QString dmCode)
{
    QDomDocument commonDOM;
    if(! Tools::loadXMLtoDOM(":/resources/blankXML/ListSubProc.xml", &commonDOM))
        return QByteArray();

    QDomNode listNode = commonDOM.namedItem("ListSubProc");
    listNode.toElement().setAttribute("dmCode", dmCode);

    for(SubProc subProc : list)
    {
        QDomNode subProcNode = commonDOM.createElement("SubProc");
        listNode.appendChild(subProcNode);
        subProcNode.toElement().setAttribute("dmCode", subProc.getDmCode());
        subProcNode.toElement().setAttribute("title", subProc.getTitle());
        subProcNode.toElement().setAttribute("canplay", subProc.getModeListStr());
    }

    Tools::saveDOMtoXML("ListSubProc.xml", &commonDOM);

    return commonDOM.toByteArray();
}
