[libxml++] Simple newbie question about reading value



<?xml version="1.0"?>
<!DOCTYPE wallpaper>

<wallpaper>
    <file> /home/knight/wallpaper/wallpaper11.jpg </file>
    <file> /home/knight/wallpaper/wallpaper12.jpg </file>
    <file> /home/knight/wallpaper/wallpaper13.jpg </file>
    <file> /home/knight/wallpaper/wallpaper14.jpg </file>
</wallpaper>

That is my xml file. I want to read this xml file and pass the value of
file to let's say array of strings. So assume we have :
string array[5];

In the end of the program I want to do this:
for( int i =0; i<4; i++)
    cout << array[i] << endl;

And the output should be 
/home/knight/wallpaper/wallpaper11.jpg
/home/knight/wallpaper/wallpaper12.jpg
/home/knight/wallpaper/wallpaper13.jpg
/home/knight/wallpaper/wallpaper14.jpg

But I don't know how to extract this value. I have read the example. But
all I know are just writing xml file, extract the reference, extract the
comment. I am getting difficulties because there is no tutorial
outthere. How can I do this? I have tried. This is my effort:
Glib::ustring filee = "wallpaper.xml";
    xmlpp::DomParser parser;
    parser.parse_file(filee);
    xmlpp::Node* pNode = parser.get_document()->get_root_node();
    xmlpp::Node::NodeList list = pNode->get_children();
    for(xmlpp::Node::NodeList::iterator iter = list.begin(); iter !=
list.end(); iter++) {
         //this is where I stuck
         //I don't know what to do here
         //there is no (*iter)->get_content(); stuff
    }

Can you help me, guyz????

Thank you.






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