Markup读取xml


bool parsePartition(char *fileName)
{
    if (fileName == NULL )
    {
        return false;
    }

    *partitionNum = 0;
    CMarkup xml;
    xml.Load(fileName);
    xml.ResetPos();
    xml.FindElem();

    CString temp;
    temp = xml.GetTagName();

    if (temp.Compare("Module") != 0)
    {
        return false;
    }

    xml.IntoElem();

    while (xml.FindElem())
    {
        temp = xml.GetTagName();
        if  (temp.Compare("Partitions") == 0)
        {
            xml.IntoElem();
            while (xml.FindElem())
            {
                temp = xml.GetTagName();
                if (temp.Compare("Partition") == 0)
                {
                    temp = xml.GetAttrib("Id");
                    int id = atoi(temp.GetBuffer(temp.GetLength()));
                    
                    temp = xml.GetAttrib("Name");
                    char szName[20]={0};
                    strcpy(szName, temp.GetBuffer(temp.GetLength()));

                }
            }
        }
    }
    return true;
}

猜你喜欢

转载自blog.csdn.net/wyyy2088511/article/details/108801442