Re: storing xml document after editing
- From: Kjell Ahlstedt <kjell ahlstedt bredband net>
- To: Santhosh Edukulla <santhosh edukulla gmail com>
- Cc: libxmlplusplus-list gnome org
- Subject: Re: storing xml document after editing
- Date: Sun, 03 Jun 2012 11:01:35 +0200
I made a test with the example program at
http://git.gnome.org/browse/libxml++/tree/examples/dom_read_write
I added the following code to main.cc, after "if(parser)":
// Add some text nodes
xmlpp::Element* root = parser.get_document()->get_root_node();
root->set_namespace_declaration("http://www.foo.org", "added_ns");
root->add_child("added_child1", "added_ns");
xmlpp::Element* child = root->add_child("added_child2");
child->set_child_text("added text in child 2");
root->set_child_text("added text in root");
The added nodes are written by "document->write_to_file(filepath_out);",
together with the original nodes.
I don't know why your added nodes are not written. If you want me to
troubleshoot for you, you must supply a complete compilable program and
any input data it may require.
Kjell
2012-06-02 13:35, Santhosh Edukulla skrev:
1/ First iam parsing the doc as below:
DomParser parser( mConfFile,false );
if( parser )
{
cout<< "SUCCESS : FILE
PARSING IS SUCCESSFUL: "<< endl ;
r =
parser.get_document()->get_root_node();
}
2/ Then adding the elements some thing like below:
for ( ;count< keys.size() ; count ++ )
{
element->add_child(
keys[count],mNbaNs );
element->set_child_text( values[count]);
}
3/ Then, iam saving as below:
xmlpp::Document* document = parser.get_document();
if( document )
document->write_to_file( mConfFile );
But, the save changes are not happening. At the same time there is no
error as well. Please let me know.
Santhosh
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]