Nicolas - 2010-09-26

Hi
I will delete a child in the main Group.
My problem is that i must search the attribute with the number from Child and then i can`t use the function delete.

XML:

<MyGames>
    <Game ID="1" NAME="BG" PATH="/abc/abc" />
    <Game ID="2" NAME="BF" PATH="/abc/abc" />
    <Game ID="3" NAME="AB" PATH="/abc/abc" />
</MyGames>

cpp:

int Game::delete_game(int number)
{
    int id;
    std::string delete_number, new_name, new_path;
    TiXmlDocument doc("./config/self.conf");
    TiXmlNode *d;
    TiXmlElement *root, *a;
    if(!doc.LoadFile())
    {
        return -6;
    }
    root = doc.RootElement();
    TiXmlHandle hdoc(root);
    for( a = hdoc.FirstChildElement("Game").ToElement(); a; a = a ->NextSiblingElement("Game") )
    {
        a ->Attribute("ID", &id);
        if(id == number)
        {
            doc.RemoveChild();
        }
        /*if(id > number)
        {
            a ->SetAttribute("ID", id-1);
        }*/
    }
    if(doc.SaveFile())
    {
        return -7;
    }
    return 0;
}

Can you help me please.

Greetings,
Nico

PS:
Sry for my english i`m from Germany :D