TinyXml解析代码

网上已经有很多关于这部分的内容,这里提供部分代码用于实例。

[in] info 条件信息  
<?xml version='1.0' encoding='utf-8' standalone='no' ?>
<root>
    <srcdomid />        发起域ID
    <starttime />       开始时间
    <endtime />         结束时间
    <type />            告警类型 -1 查询全部 其它查询指定
    <domid />           设备域ID
    <devcode />         通道设备代码,比如"'chn0','chn1','chn2'"
    <chnidx />          通道序号
    <domdevcode />      设备域ID+设备代码,比如"'chn0','chn1','chn2'@domid1; 'chn0','chn1','chn2'@domid2"
    <size />            每页大小
    <curpage />         查询第几页
</root>

[out] outxml 返回信息 <?xml version='1.0' encoding='utf-8' standalone='no' ?>
<root>
    <total></total>             总数
    <item 
        id=""                   告警记录ID
        domid=""ID
        devcode=""              设备代码
        devname=""              设备名称
        chnidx=""               通道索引
        devtype=""              设备类型
        type=""                 告警类型
        status=""               状态
        level=""                告警等级
        alarmtime=""            告警时间
        length=""               数据长度
        msgtxt=""               消息文本
        confirmor=""            确认人
        confirmtime=""          确认时间
        comfirmmsg=""           确认消息
        comfirmstatus=""        确认状态
    />
</root>

代码实例:

#ifndef _ALARM_INFO_REQ_XML_H
#define _ALARM_INFO_REQ_XML_H

#include <vector>
#include <string>
#include "tinyxml.h"
#include "tinyxmldefine.h"
#include "XMLParser.h"

#define  XML_NODE_COUNT 7

class  CXMLProduce : public CXMLParser
{
public:
    CXMLProduce();
    virtual ~CXMLProduce();

public:
    int fromStream(const char *data);
    int toStream(char *buf, int &nLen);

    int fromStreamHisAlarm(const char *data);
    int toStreamHisAlarm(char *buf, int &nLen);

    int fromStreamHisRealData(const char *data);
    int toStreamHisRealData(char *buf, int &nLen);

    int toStreamDevHisRealData(char *buf, int &nLen);
    int fromStreamDevHisRealData(const char *data);//历史查询中历史数据


    void initialVector();
    void setDomid(const char *szDomid);
    void setSrcdomid(const char *szsrcdomid);
    void setStartTime(const char *szStartTime);
    void setEndTime(const char *szEndTime);
    void setType(int Type);
    void setDevcode(const char *szDevcode);
    void setDomDevcode(const char *szDomDevcode);
    void setChnidx(int Chnidx);
    void setCurpage(int Curpage);
    void setSize(int Size);


    int fromStreamQueryConfirmMsg(const char *data);
    int toStreamQueryConfirmMsg(char *buf, int &nLen);

protected:
    int packetXmlInside(TiXmlDocument &doc);
    int parseXmlInside(TiXmlDocument &doc);

    int packetXmlInsideHisAlarm(TiXmlDocument &doc);
    int parseXmlInsideHisAlarm(TiXmlDocument &doc);

    int packetXmlInsideHisRealData(TiXmlDocument &doc);
    int parseXmlInsideHisRealData(TiXmlDocument &doc);

    int packetXmlInsideDevHisRealData(TiXmlDocument &doc);//历史查询中历史数据
    int parseXmlInsideDevHisRealData(TiXmlDocument &doc);

    int packetXmlInsideQueryConfirmData(TiXmlDocument &doc);
    int parseXmlInsideQueryConfirmData(TiXmlDocument &doc);

public:
    int m_pageSize;
    int m_alarmTotal;
    AlarmInfo_t m_alarmInfo;

    char m_strDomid[64];
    char m_strDevcode[64];
    char m_strSrcdomid[64];
    char m_strStartTime[64];
    char m_strEndTime[64];
    int  m_strType;
    int  m_strCurpage;
    int m_strSize;
    int m_strChnidx;
    char m_strDomdevcode[64];

    HistoryAlarmDataInfo_t m_DeviceAlarmHisInfo;
    vector<string> vec;

    SCS_HistoryDataInfo_t m_MapDoorHisRealData;
    SCS_HistoryDataInfo_t m_MapDevHisRealData;

    std::list<_AlarmConfirm> m_confirmMsg;
};
#endif
#include "AlarmInfoReqXML.h"
#include <iostream>
#include<sstream>
#include"cstdio"
#include "string"

CXMLProduce::CXMLProduce()
{
    initialVector();
}
CXMLProduce::~CXMLProduce()
{

}

/********* 解析XML文件  *********/

int CXMLProduce::fromStream(const char *data)
{
    TiXmlDocument doc;
    doc.Parse(data);

    return parseXmlInside(doc);
}

int CXMLProduce::fromStreamHisAlarm(const char *data)
{
    TiXmlDocument doc;
    doc.Parse(data);

    return parseXmlInsideHisAlarm(doc);
}

int CXMLProduce::fromStreamHisRealData(const char *data)
{
    TiXmlDocument doc;
    doc.Parse(data);

    return parseXmlInsideHisRealData(doc);
}

int CXMLProduce::fromStreamDevHisRealData(const char *data)
{
    TiXmlDocument doc;
    doc.Parse(data);

    return parseXmlInsideDevHisRealData(doc);
}

int CXMLProduce::fromStreamQueryConfirmMsg(const char *data)
{
    TiXmlDocument doc;
    doc.Parse(data);

    return parseXmlInsideQueryConfirmData(doc);
}

int CXMLProduce::parseXmlInside(TiXmlDocument &doc)
{
    TiXmlElement *pRoot = doc.FirstChildElement("root");
    if(pRoot == nullptr)
    {
        return -1;  
    }

    TiXmlElement *pElement = pRoot->FirstChildElement("total");
    if (pElement != nullptr)
    {
        m_alarmTotal = atoi(pElement->GetText());
        m_alarmInfo.count =m_alarmTotal;
    }

    pElement = pRoot->FirstChildElement("taskrecord");
    while (pElement != nullptr)
    {
        AlarmInfoItem_t item;
        item.flag = -1;

        pElement->Attribute("id", &item.id);
        item.domid = pElement->Attribute("domid");
        item.devcode = pElement->Attribute("devcode");
        item.devname = pElement->Attribute("devname");
        item.orgname = pElement->Attribute("orgname");
        item.time = pElement->Attribute("time");
        item.result = pElement->Attribute("result");

        pElement->Attribute("type", &item.type);
        pElement->Attribute("alarmlevel", &item.alarm_level);

        XmlNodeKey node(item.domid, item.devcode);
        m_alarmInfo.items[node] = item;
        pElement = pElement->NextSiblingElement();
    }

    return 0;
}

int CXMLProduce::parseXmlInsideHisAlarm(TiXmlDocument &doc)
{
    TiXmlElement *pRoot = doc.FirstChildElement("root");
    if(pRoot == nullptr)
    {
        return -1;  
    }

    m_DeviceAlarmHisInfo.items.clear();
    TiXmlElement *pElement = pRoot->FirstChildElement("total");
    if (pElement != nullptr)
    {
        m_DeviceAlarmHisInfo.count = atoi(pElement->GetText());
    }

    pElement = pRoot->FirstChildElement("item");
    while (pElement != nullptr)
    {
        AlarmInfoItem_t alarmItem;
        string keyCode;
        alarmItem.flag = -1;
        pElement->Attribute("id", &alarmItem.id);
        alarmItem.domid= pElement->Attribute("domid");
        alarmItem.devcode = pElement->Attribute("devcode");
        alarmItem.chnname=pElement->Attribute("chnname");
        std::stringstream stream;
        stream<<alarmItem.id;
        keyCode=stream.str();
        alarmItem.devname = pElement->Attribute("devname");
        alarmItem.alarmtime = pElement->Attribute("alarmtime");
        pElement->Attribute("level", &alarmItem.alarm_level);
        pElement->Attribute("type", &alarmItem.hisalarm_type);
        pElement->Attribute("status",&alarmItem.status);

        m_DeviceAlarmHisInfo.items[keyCode] = alarmItem;
        pElement = pElement->NextSiblingElement();
    }

    return 0;
}

int CXMLProduce::parseXmlInsideHisRealData(TiXmlDocument &doc)
{
    TiXmlElement *pRoot = doc.FirstChildElement("root");
    if(pRoot == nullptr)
    {
        return -1;  
    }

    TiXmlElement *pElement = pRoot->FirstChildElement("total");
    if (pElement != nullptr)
    {
        int totalNum = atoi(pElement->GetText());
        m_MapDoorHisRealData.totalNum =totalNum;
    }

    pElement = pRoot->FirstChildElement("item");

    while (pElement != nullptr)
    {
        SCS_RealData hisDoorRealDataItem;

        TiXmlAttribute *xmlAttri = nullptr;
        xmlAttri = pElement->FirstAttribute();
        if (xmlAttri != nullptr)
        {
            hisDoorRealDataItem._domainId = xmlAttri->Value();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            hisDoorRealDataItem._deviceCode = xmlAttri->Value();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            hisDoorRealDataItem._chnName = xmlAttri->Value();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            hisDoorRealDataItem._alarmtype = xmlAttri->IntValue();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            hisDoorRealDataItem._isAlarm = xmlAttri->IntValue();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            const char *pTime = xmlAttri->Value();
            std::string strTime(pTime);
            hisDoorRealDataItem._time = strTime;
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {

            hisDoorRealDataItem._value = xmlAttri->DoubleValue();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            hisDoorRealDataItem._strunit = xmlAttri->Value();
        }


        if (xmlAttri != nullptr)
        {
            std::string strCodeTime("");
            strCodeTime.append(hisDoorRealDataItem._deviceCode);
            strCodeTime.append("@");
            strCodeTime.append(hisDoorRealDataItem._time);
            char buffer[20];
            sprintf_s(buffer,"f",hisDoorRealDataItem._value);
            string str=buffer;
            strCodeTime.append(str);

            m_MapDoorHisRealData.devRealDataMap[strCodeTime] = hisDoorRealDataItem;
        }

        pElement = pElement->NextSiblingElement();

    }
    return 0;
}
int CXMLProduce::parseXmlInsideDevHisRealData(TiXmlDocument &doc)
{
    TiXmlElement *pRoot = doc.FirstChildElement("root");
    if(pRoot == nullptr)
    {
        return -1;  
    }

    TiXmlElement *pElement = pRoot->FirstChildElement("total");
    if (pElement != nullptr)
    {
        int totalNum = atoi(pElement->GetText());
        m_MapDevHisRealData.totalNum =totalNum;
    }

    pElement = pRoot->FirstChildElement("item");

    while (pElement != nullptr)
    {
        SCS_RealData devHisRealDataItem;
        TiXmlAttribute *xmlAttri = nullptr;
        xmlAttri = pElement->FirstAttribute();
        if (xmlAttri != nullptr)
        {
            devHisRealDataItem._domainId = xmlAttri->Value();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            devHisRealDataItem._deviceCode = xmlAttri->Value();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            devHisRealDataItem._chnName = xmlAttri->Value();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            devHisRealDataItem._alarmtype = xmlAttri->IntValue();
            xmlAttri = xmlAttri->Next();
        }
        if (xmlAttri != nullptr)
        {
            devHisRealDataItem._isAlarm = xmlAttri->IntValue();
            xmlAttri = xmlAttri->Next();
        }
        if (xmlAttri != nullptr)
        {
            const char *pTime = xmlAttri->Value();
            std::string strTime(pTime);
            devHisRealDataItem._time = strTime;
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            devHisRealDataItem._value = xmlAttri->DoubleValue();
            xmlAttri = xmlAttri->Next();
        }

        if (xmlAttri != nullptr)
        {
            devHisRealDataItem._strunit = xmlAttri->Value();
        }


        if (xmlAttri != nullptr)
        {
            std::string strCodeTime("");
            strCodeTime.append(devHisRealDataItem._deviceCode);
            strCodeTime.append("@");
            strCodeTime.append(devHisRealDataItem._time);

            char buffer[20];
            sprintf_s(buffer,"f",devHisRealDataItem._value);
            string str=buffer;
            strCodeTime.append(str);

            m_MapDevHisRealData.devRealDataMap[strCodeTime] = devHisRealDataItem;
        }

        pElement = pElement->NextSiblingElement();

    }
    return 0;
}

int CXMLProduce::parseXmlInsideQueryConfirmData(TiXmlDocument &doc)
{
    TiXmlElement *pRoot = doc.FirstChildElement("root");
    if(pRoot == nullptr)
    {
        return -1;  
    }

    TiXmlElement *pElement = pRoot->FirstChildElement("taskrecord");

    while (pElement != nullptr)
    {
        _AlarmConfirm item;

        pElement->Attribute("id", &item.alarmId);

        const char *pTime = pElement->Attribute("dealtime");
        if (pTime != nullptr)
        {
            item.confirm_time = pTime;
        }

        const char *pPerson = pElement->Attribute("dealperson");
        if (pPerson != nullptr)
        {
            item.dealperson = pPerson;
        }

        const char *pMsg = pElement->Attribute("dealresult");
        if (pMsg != nullptr)
        {
            item.confirm_msg = pMsg;
        }

        m_confirmMsg.push_back(item);

        pElement = pElement->NextSiblingElement();
    }

    return 0;
}



int CXMLProduce::toStream(char *buf, int &nLen)
{
    if (buf == nullptr)
    {
        return -2;
    }

    TiXmlDocument doc;
    int res = packetXmlInside(doc);
    if (res < 0)
    {
        return res;
    }

    TiXmlPrinter printer;
    doc.Accept(&printer);
    strcpy(buf, printer.CStr());
    nLen = printer.Size();

    return 0;
}

int CXMLProduce::toStreamHisAlarm(char *buf, int &nLen)
{
    if (buf == nullptr)
    {
        return -2;
    }

    TiXmlDocument doc;
    int res = packetXmlInsideHisAlarm(doc);
    if (res < 0)
    {
        return res;
    }

    TiXmlPrinter printer;
    doc.Accept(&printer);
    strcpy(buf, printer.CStr());
    nLen = printer.Size();

    return 0;
}

int CXMLProduce::toStreamHisRealData(char *buf, int &nLen)
{
    if (buf == nullptr)
    {
        return -2;
    }

    TiXmlDocument doc;
    int res = packetXmlInsideHisRealData(doc);
    if (res < 0)
    {
        return res;
    }

    TiXmlPrinter printer;
    doc.Accept(&printer);
    strcpy(buf, printer.CStr());
    nLen = printer.Size();

    return 0;
}

int CXMLProduce::toStreamQueryConfirmMsg(char *buf, int &nLen)
{
    if (buf == nullptr)
    {
        return -2;
    }

    TiXmlDocument doc;
    int res = packetXmlInsideQueryConfirmData(doc);
    if (res < 0)
    {
        return res;
    }

    TiXmlPrinter printer;
    doc.Accept(&printer);
    strcpy(buf, printer.CStr());
    nLen = printer.Size();

    return 0;
}


///

int CXMLProduce::packetXmlInside(TiXmlDocument &doc)
{

    TiXmlDeclaration *del = new TiXmlDeclaration("1.0", "'utf-8", "no");
    if( doc.LinkEndChild(del) == nullptr)
    {
        return -3;
    }

    TiXmlElement *pRoot = new TiXmlElement("root");
    if (doc.LinkEndChild(pRoot) == nullptr)
    {
        return -4;
    }



    TiXmlElement *pdomidElement = new TiXmlElement("domid");

    TiXmlText textDomid(m_strDomid);
    pdomidElement->InsertEndChild(textDomid);

    TiXmlElement *psizeElement = new TiXmlElement("size");
    char bufSize[64] = {0};
    m_pageSize = 500;
    _snprintf_s(bufSize, sizeof(bufSize), "%d", m_pageSize);
    TiXmlText textSize(bufSize);
    psizeElement->InsertEndChild(textSize);

    TiXmlElement *pcurpageElement = new TiXmlElement("curpage");
    char bufCuepage[64] = {0};
    _snprintf_s(bufCuepage, sizeof(bufCuepage), "%d", 0);
    TiXmlText textCurpage(bufCuepage);
    pcurpageElement->InsertEndChild(textCurpage);


    pRoot->LinkEndChild(pdomidElement);
    pRoot->LinkEndChild(psizeElement);
    pRoot->LinkEndChild(pcurpageElement);

    return 0;
}

int CXMLProduce::packetXmlInsideHisAlarm(TiXmlDocument &doc)
{
    TiXmlDeclaration *del = new TiXmlDeclaration("1.0", "'utf-8", "no");
    if( doc.LinkEndChild(del) == nullptr)
    {
        return -3;
    }

    TiXmlElement *pRoot = new TiXmlElement("root");
    if (doc.LinkEndChild(pRoot) == nullptr)
    {
        return -4;
    }
    TiXmlElement *psrcdomidElement = new TiXmlElement("srcdomid");
    TiXmlText textSrcDomid(m_strSrcdomid);
    psrcdomidElement->InsertEndChild(textSrcDomid);

    TiXmlElement *pstartElement = new TiXmlElement("starttime");
    TiXmlText textStartTime(m_strStartTime);
    pstartElement->InsertEndChild(textStartTime);

    TiXmlElement *pendElement = new TiXmlElement("endtime");
    TiXmlText textEndTime(m_strEndTime);
    pendElement->InsertEndChild(textEndTime);

    TiXmlElement *ptypeElement = new TiXmlElement("type");
    char bufType[64]={0};
    //m_strType= -1;
    _snprintf_s(bufType, sizeof(bufType), "%d",m_strType );
    TiXmlText textType(bufType);
    ptypeElement->InsertEndChild(textType);


    TiXmlElement *pdomidElement = new TiXmlElement("domid");
    TiXmlText textDomid(m_strDomid);
    pdomidElement->InsertEndChild(textDomid);

    TiXmlElement *pdevcodeElement = new TiXmlElement("devcode");
    char bufDevcode[64] = {0};
    _snprintf_s(bufDevcode, sizeof(bufDevcode), "\'%s\'", m_strDevcode);
    TiXmlText textDevcode(m_strDevcode);
    pdevcodeElement->InsertEndChild(textDevcode);



    TiXmlElement *pchnidxElement = new TiXmlElement("chnidx");
    char bufChnidx[64]={0};
    _snprintf_s(bufChnidx, sizeof(bufChnidx), "%d", m_strChnidx);
    TiXmlText textChnidx(bufChnidx);
    pchnidxElement->InsertEndChild(textChnidx);

    TiXmlElement *pdomdevElement = new TiXmlElement("domdevcode");
    TiXmlText textDomdevcode(m_strDomdevcode);
    pdomdevElement->InsertEndChild(textDomdevcode);


    TiXmlElement *psizeElement = new TiXmlElement("size");
    char bufSize[64] = {0};

    _snprintf_s(bufSize, sizeof(bufSize), "%d", m_strSize);
    TiXmlText textSize(bufSize);
    psizeElement->InsertEndChild(textSize);

    TiXmlElement *pcurpageElement = new TiXmlElement("curpage");
    char bufCurpage[64]={0};

    _snprintf_s(bufCurpage, sizeof(bufSize), "%d", m_strCurpage);
    TiXmlText textCurpage(bufCurpage);
    pcurpageElement->InsertEndChild(textCurpage);


    pRoot->LinkEndChild(psrcdomidElement);
    pRoot->LinkEndChild(pstartElement);
    pRoot->LinkEndChild(pendElement);
    pRoot->LinkEndChild(ptypeElement);
    pRoot->LinkEndChild(pdomidElement);
    pRoot->LinkEndChild(pdevcodeElement);
    pRoot->LinkEndChild(pchnidxElement);
    pRoot->LinkEndChild(pdomdevElement);
    pRoot->LinkEndChild(psizeElement);
    pRoot->LinkEndChild(pcurpageElement);       
    return 0;
}

int CXMLProduce::packetXmlInsideHisRealData(TiXmlDocument &doc)
{
    TiXmlDeclaration *del = new TiXmlDeclaration("1.0", "'utf-8", "no");
    if( doc.LinkEndChild(del) == nullptr)
    {
        return -3;
    }

    TiXmlElement *pRoot = new TiXmlElement("root");
    if (doc.LinkEndChild(pRoot) == nullptr)
    {
        return -4;
    }
    TiXmlElement *psrcdomidElement = new TiXmlElement("srcdomid");
    TiXmlText textSrcDomid(m_strSrcdomid);
    psrcdomidElement->InsertEndChild(textSrcDomid);

    TiXmlElement *pstartElement = new TiXmlElement("starttime");
    TiXmlText textStartTime(m_strStartTime);
    pstartElement->InsertEndChild(textStartTime);

    TiXmlElement *pendElement = new TiXmlElement("endtime");
    TiXmlText textEndTime(m_strEndTime);
    pendElement->InsertEndChild(textEndTime);


    TiXmlElement *pdomidElement = new TiXmlElement("domid");
    TiXmlText textDomid(m_strDomid);
    pdomidElement->InsertEndChild(textDomid);

    TiXmlElement *pdevcodeElement = new TiXmlElement("devcode");
    TiXmlText textDevcode(m_strDevcode);
    pdevcodeElement->InsertEndChild(textDevcode);

    TiXmlElement *psizeElement = new TiXmlElement("size");
    char bufSize[64] = {0};

    _snprintf_s(bufSize, sizeof(bufSize), "%d", m_strSize);
    TiXmlText textSize(bufSize);
    psizeElement->InsertEndChild(textSize);

    TiXmlElement *pcurpageElement = new TiXmlElement("curpage");
    char bufCurpage[64]={0};

    _snprintf_s(bufCurpage, sizeof(bufSize), "%d", m_strCurpage);
    TiXmlText textCurpage(bufCurpage);
    pcurpageElement->InsertEndChild(textCurpage);


    pRoot->LinkEndChild(psrcdomidElement);
    pRoot->LinkEndChild(pstartElement);
    pRoot->LinkEndChild(pendElement);
    pRoot->LinkEndChild(pdomidElement);
    pRoot->LinkEndChild(pdevcodeElement);
    pRoot->LinkEndChild(psizeElement);
    pRoot->LinkEndChild(pcurpageElement);       
    return 0;
}


int CXMLProduce::packetXmlInsideQueryConfirmData(TiXmlDocument &doc)
{
    TiXmlDeclaration *del = new TiXmlDeclaration("1.0", "utf-8", "no");
    if( doc.LinkEndChild(del) == nullptr)
    {
        return -3;
    }

    TiXmlElement *pRoot = new TiXmlElement("root");
    if (doc.LinkEndChild(pRoot) == nullptr)
    {
        return -4;
    }

    TiXmlElement *pdomidElement = new TiXmlElement("domid");
    TiXmlText textDomid(m_strDomid);
    pdomidElement->InsertEndChild(textDomid);

    TiXmlElement *pdevcodeElement = new TiXmlElement("devcode");
    TiXmlText textDevcode(m_strDevcode);
    pdevcodeElement->InsertEndChild(textDevcode);

    TiXmlElement *pstartElement = new TiXmlElement("starttime");
    TiXmlText textStartTime(m_strStartTime);
    pstartElement->InsertEndChild(textStartTime);

    TiXmlElement *pendElement = new TiXmlElement("endtime");
    TiXmlText textEndTime(m_strEndTime);
    pendElement->InsertEndChild(textEndTime);

    TiXmlElement *psizeElement = new TiXmlElement("size");
    char bufSize[64] = {0};

    _snprintf_s(bufSize, sizeof(bufSize), "%d", m_strSize);
    TiXmlText textSize(bufSize);
    psizeElement->InsertEndChild(textSize);

    TiXmlElement *pcurpageElement = new TiXmlElement("curpage");
    char bufCurpage[64]={0};

    _snprintf_s(bufCurpage, sizeof(bufSize), "%d", m_strCurpage);
    TiXmlText textCurpage(bufCurpage);
    pcurpageElement->InsertEndChild(textCurpage);

    //将元素加入root
    pRoot->LinkEndChild(pdomidElement);
    pRoot->LinkEndChild(pdevcodeElement);
    pRoot->LinkEndChild(pstartElement);
    pRoot->LinkEndChild(pendElement);
    pRoot->LinkEndChild(psizeElement);
    pRoot->LinkEndChild(pcurpageElement);       
    return 0;
}


void CXMLProduce::setDomid(const char *szDomid)
{
    if(szDomid!=nullptr)
    {
        strcpy_s(m_strDomid,szDomid);
    }   
}
void CXMLProduce::setSrcdomid(const char *szsrcdomid)
{
    if(szsrcdomid!=nullptr)
    {
        strcpy_s(m_strSrcdomid,szsrcdomid);
    }
}
void CXMLProduce::setStartTime(const char *szStartTime)
{
    if(szStartTime!=nullptr)
    {
        strcpy_s(m_strStartTime, szStartTime);
    }

}
void CXMLProduce::setEndTime(const char *szEndTime)
{
    if(szEndTime!=nullptr)
    {
        strcpy_s(m_strEndTime, szEndTime);
    }   
}
void CXMLProduce::setType(int Type)
{
    m_strType= Type;
}
void CXMLProduce::setDevcode(const char *szDevcode)
{
    if(szDevcode!=nullptr)
    {
        strcpy_s(m_strDevcode, szDevcode);
    }   
}
void CXMLProduce::setChnidx(int Chnidx)
{
    m_strChnidx=Chnidx;
}
void CXMLProduce::setDomDevcode(const char *szDomDevcode)
{
    if(szDomDevcode!=nullptr)
    {
        strcpy_s(m_strDomdevcode, szDomDevcode);
    }   
}
void CXMLProduce::setSize(int size)
{
    m_strSize=size;
}
void CXMLProduce::setCurpage(int Curpage)
{
    m_strCurpage= Curpage;
}

void CXMLProduce::initialVector()
{
    vec.push_back("srcdomid");
    vec.push_back("starttime");
    vec.push_back("endtime");
    vec.push_back("domid");
    vec.push_back("devcode");
    vec.push_back("size");
    vec.push_back("curpage");
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值