Re: [libxml++] Simple newbie question about reading value



On Mon, 2004-05-10 at 11:29, Jim Garrison wrote:
> xmlpp::Element *el = dynamic_cast<xmlpp::Element*>(*iter);
> if (!el)
>   continue;
> xmlpp::TextNode *t = el->get_child_text();
> if (!t)
>   continue;
> t->get_content(); // and do something with it.
> 
> Let me know if that doesn't work.
Thanks, that works!!!

> 
> Jim
> 
> On Sun, 2004-05-09 at 13:49, Akbar wrote:
> > <?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.
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > This SF.Net email is sponsored by Sleepycat Software
> > Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to 
> > deliver higher performing products faster, at low TCO.
> > http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
> > _______________________________________________
> > Libxmlplusplus-general mailing list
> > Libxmlplusplus-general lists sourceforge net
> > https://lists.sourceforge.net/lists/listinfo/libxmlplusplus-general
> 




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