Re: Compiler Errors
- From: Kjell Ahlstedt <kjell ahlstedt bredband net>
- To: Santhosh Edukulla <santhosh edukulla gmail com>
- Cc: libxmlplusplus-list gnome org
- Subject: Re: Compiler Errors
- Date: Fri, 01 Jun 2012 19:31:13 +0200
When I run your example, it crashes on
txt_node = node_element->get_child_text();
because node_element == NULL.
mRNode has 5 children:
1. a TextNode containing a linefeed ("\n")
2. an f1 Element node
3. a TextNode containing a linefeed
4. an f2 Element node
5. a TextNode containing a linefeed
If you are only interested in f1 nodes, change
Node::NodeList temp_lst = mRNode->get_children();
to
Node::NodeList temp_lst = mRNode->get_children("f1");
or make more tests when you loop over all the children.
Kjell
2012-06-01 12:44, Santhosh Edukulla skrev:
Team,
1/ I have a file with few nodes as below. Iam using the code mentioned
below to parse this file. Everytime, i run with hundreds of changes
but in vain the result is same i.e., it gets crashed. May i know as
what iam doing wrong? I have given up after 3 hours of spending time
on this. Also, documentation wise and help wise, it need some
improvement i believe. I wanted to retrieve content of a given node.
This is very easy with other dom parsers compared to here.
It crashes at the below statement.
mConfigFilePath = txt_node->get_content();
Some how
<f>
<f1>abc</f1>
<f2>abc</f2>
</f>
string temp_str,temp_name;
Element* node_element;
TextNode *txt_node,*txt_node1;
DomParser parser( "abc.xml",false );
if( parser )
{
cout<< "SUCCESS : FILE PARSING IS
SUCCESSFUL: "<< endl ;
mRNode = parser.get_document()->get_root_node();
}
/*Check if op file is able to be parsed*/
if( mRNode != NULL )
Node::NodeList temp_lst = mRNode->get_children();
for( Node::NodeList::iterator temp_node =
temp_lst.begin(); temp_node != temp_lst.end(); ++temp_node )
{
temp_str = (*temp_node)->get_name();
node_element = dynamic_cast<Element*>(*temp_node);
txt_node = node_element->get_child_text();
if ( temp_str == "config_file" )
{
mConfigFilePath = txt_node->get_content();
}
2/ Also, I believe, it was made way too complicated i believe. I have
a node f1, i just wanted to retrieve its content. Instead we made a
TextNode,Element Node etc.
This is typically different from other parsers available under c#.net and java.
Santhosh
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]