Element creation



Hi,

I need to create a xml document and save it to a file.
I create the xml using the below code.

xmlpp::Document doc;
xmlpp::Element* pRootEle = doc.create_root_node("root");

xmlpp::Element* pNode = pRootEle->add_child("node1");
pNode->add_child_text("node1 data");

But i need to create a list of Elements in a function and directly add it
as a child to the root node. some thing like below.

list<Element *> eleList = getAllNodes();
foreach(Element ele in eleList)
{
    pRootEle -> add_child(ele);
}

How can i achieve it. I don't want to pass the rootnode to the function.

regards,
Jaya


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]