LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-13-2004, 02:30 AM   #1
shilpig
LQ Newbie
 
Registered: May 2004
Posts: 8

Rep: Reputation: 0
xml parser in linux


I am new to xml but have come to know that xml files are best way to use as application specific configuration files.

Now I need help on how to create a xml file and then later read this xml file through linux program.

Thanx
Shilpi
 
Old 05-13-2004, 11:24 AM   #2
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Rep: Reputation: 31
Code:
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++) {
        xmlpp::Element *el = dynamic_cast<xmlpp::Element*>(*iter);
        if(!el)
            continue;
        xmlpp::TextNode *t = el->get_child_text();
        if(!t)
            continue;
        cout << t->get_content() << endl;
    }
This is my file:
<?xml version="1.0"?>
<!DOCTYPE wallpaper>

<wallpaper>
<!-- this is comment -->
<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>

I use C++ language.
http://libxmlplusplus.sf.net

Other reference:
http://www-106.ibm.com/developerwork...y/x-ctlbx.html

Don't hesitate to ask questions.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for XML::Parser... configure: error: XML::Parser perl module is required for kornerr Linux - General 11 11-16-2008 07:24 AM
XML Parser bulkman Linux - Software 6 04-29-2005 07:01 AM
gDesklets and the xml parser doralsoral Linux - Software 1 05-08-2004 11:56 AM
Galeon and XML::Parser virus2099 Slackware 1 01-20-2004 06:11 PM
_simple_ regex XML parser poison Programming 0 01-02-2004 08:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration