Re: Compiler Errors
- From: Santhosh Edukulla <santhosh edukulla gmail com>
- To: Kjell Ahlstedt <kjell ahlstedt bredband net>
- Cc: libxmlplusplus-list gnome org
- Subject: Re: Compiler Errors
- Date: Fri, 1 Jun 2012 16:14:58 +0530
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
On 5/28/12, Kjell Ahlstedt <kjell ahlstedt bredband net> wrote:
> 2012-05-28 13:26, Santhosh Edukulla skrev:
>> Hi Kjell,
>>
>> Thanks for the info. As well what is the diff between textnode\content
>> node?
>>
>> Iam trying to add some thing like this. I already have f in my xml. Is
>> f1 a text\content node?
>>
>> Iam using add_child("f1") and then setting text using
>> set_child_text("abc");
>>
>> Is it right?
>>
>> <f>
>> <f1>abc</f1>
>> </f>
>>
>> Santhosh
>>
>>
> f1 is an element node, and "abc" is the contents of a text node, which
> is a child of f1.
> You can look at the example program
> http://git.gnome.org/browse/libxml++/tree/examples/dom_build/main.cc
> and the output from it when you run it.
>
> I'm not sure what you mean by "the diff between textnode\content node".
> xmlpp::TextNode is a subclass of xmlpp::ContentNode. libxml++ does not
> create ContentNode objects, but it does create objects of ContentNode's
> subclasses.
>
> Kjell
>
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]