[libxml++] DOmParser get node value


 
Thread Tools Search this Thread
Top Forums Programming [libxml++] DOmParser get node value
# 1  
Old 05-14-2010
[libxml++] DOmParser get node value

Hi
I wrote the follow code:

Code:
this->domParser = new xmlpp::DomParser();
this->domParser->set_validate(true);
this->domParser->parse_file(*this->xmlFileName);
this->doc = this->domParser->get_document();

xmlpp::Node* rootNode = this->doc->get_root_node();
xmlpp::Node::NodeList list = rootNode->get_children();
std::cout << "Nodes count: " << list.size() << std::endl;
xmlpp::Node::NodeList::iterator itr = list.begin();

itr.operator ++(1);
xmlpp::ContentNode *cn = static_cast<xmlpp::ContentNode*>(itr.operator *());
std::cout << cn->get_name() << std::endl;
std::cout << cn->get_content() << std::endl;

My XML file is:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE config SYSTEM "scheduler.config.dtd">
<config>
    <abspath><![CDATA[/home/matsuo]]></abspath>
    <confdir><![CDATA[conf]]></confdir>
    <logdir><![CDATA[log]]></logdir>
    <registrationdir><![CDATA[registration]]></registrationdir>
    <fileconf><![CDATA[scheduler.config.xml]]></fileconf>
    <schedulerlogdir><![CDATA[scheduler]]></schedulerlogdir>
    <schedulertime><![CDATA[890]]></schedulertime>
    <schedulerstoptime><![CDATA[900]]></schedulerstoptime>
    <schedulerremovetime><![CDATA[1000]]></schedulerremovetime>
    <hostsfile><![CDATA[hosts.list]]></hostsfile>
</config>

I riceve this message:
XML Error exception: this node type doesn't have content

on:
Code:
std::cout << cn->get_content() << std::endl;

what is my error please
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. HP-UX

Mount FIle systems from node-1 onto node-2

Hi, We have HP UX service guard cluster on OS 11.23. Recently 40+ LUNs presented to both nodes by SAN team but I was asked to mount them on only one node. I created required VGs/LVs, created VxFS and mounted all of them and they are working fine. Now client requested those FS on 2nd node as... (4 Replies)
Discussion started by: prvnrk
4 Replies

2. Homework & Coursework Questions

Accessing one UNIX node from another node of the same server

Hi Experts, I am in need of running a script from one node say node 1 via node 2. My scheduling tool dont have access to node2 , so i need to invoke the list file from node1 but the script needs to run from node2. because the server to which i am hitting, is having access only for the node... (5 Replies)
Discussion started by: arun1377
5 Replies

3. Programming

Help in libxml++ for Linux

Hi, Using libxml++-2.6, is it possible to change the xsi:noNamespaceSchemaLocation in the root element node? e.g. from <myxml xsi:noNamespaceSchemaLocation="ABC.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> : : </myxml> to <myxml... (1 Reply)
Discussion started by: tanlccc
1 Replies

4. Shell Programming and Scripting

How to nodetype as "ELEMENT_NODE" using xml::libxml in perl?

Hi, I am using xml::libxml. Here is the code. my $parser = XML::LibXML->new(); my $xmldoc = $parser->parse_file ("file.xml") || die("Could not parse config xml file\n"); my $root = $xmldoc->getDocumentElement()|| die("Could not get Document Element \n"); $id="121313131"; # For example... (2 Replies)
Discussion started by: vanitham
2 Replies

5. Solaris

SVM metaset on 2 node Solaris cluster storage replicated to non-clustered Solaris node

Hi, Is it possible to have a Solaris cluster of 2 nodes at SITE-A using SVM and creating metaset using say 2 LUNs (on SAN). Then replicating these 2 LUNs to remote site SITE-B via storage based replication and then using these LUNs by importing them as a metaset on a server at SITE-B which is... (0 Replies)
Discussion started by: dn2011
0 Replies

6. Shell Programming and Scripting

i-node address

how would i show all i-node addresses of all files in my directory (1 Reply)
Discussion started by: trob
1 Replies

7. Programming

libxml c

I've just started using libxml in c++, so far im able to parse a xml string. now i would like to replace <cms:CMSContent id="leftNav" /> with the string "left" and write the new xml out to cout; any ideas? string.xml <html xmlns:cms="http://www.test.com"> <body> <cms:CMSContent id="leftNav"... (1 Reply)
Discussion started by: spids
1 Replies

8. Programming

libxml c

i have xml file like this <root> <sree> <cnu value="cprogramming"\> </sree> </root> to retrieve the valuse of cnu element i tried the following code Code: void parseDoc() { xmlDocPtr doc; xmlNodePtr cur; doc = xmlParseFile("/usr/share/1.xml"); if (doc == NULL ) {... (1 Reply)
Discussion started by: phani_sree
1 Replies
Login or Register to Ask a Question