remove_node in rapidxml

Dear all,

Having the following xml file:
<A>
<B/>
<B attr1="value1" attr2="value2" />
<C>
<D />
<E attr1="value3" />
<E attr1="value4" />
<F />
</C>
</A>

Please, help me to debug the following code.
Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <iostream>
#include "rapidxml/rapidxml.hpp"
#include "rapidxml/rapidxml_utils.hpp"
#include "rapidxml/rapidxml_print.hpp"
using namespace rapidxml;

int main()
{
	file<> xmlFile("example_t.xml");
	xml_document<> doc;
	doc.parse<0>(xmlFile.data());
	//
	xml_node<> *pA=doc.first_node();
	//
	xml_node<> *pC=pA->first_node("C");
	xml_node::remove_node(pC->first_node("E"));
	//save
	std::ofstream newfile;
	newfile << "<?xml version=\"1.0\" encoding=\"utf-8\"?>" << std::endl;
	newfile.open("output.xml");
	newfile<<doc;
	return 0;
}
Last edited on
Your XML file is pretty generic so it is very hard to debug.
Good luck if you find someone who knows RapidXML specifically.
Topic archived. No new replies allowed.