hi every body
i'm new to c++ and xerces. i'm triying to make change in an xml file using xerces dom parser. my xml file which i want to change is following : its name is sel.xml
if ( root )
{
cout<<"hi\n";
DOMElement* property = dynamic_cast<DOMElement*>( root->getElementsByTagName( tag )->item( 0) );
if ( property )
{
cout<<"hello";
DOMElement* name = dynamic_cast<DOMElement*>( property->getElementsByTagName( tag2 )->item( 0 ) );
if ( name )
{
cout<<"\nmanish\n";
DOMElement* value = dynamic_cast<DOMElement*>( property->getElementsByTagName( tag1 )->item( 0 ) );
if ( value )
{
cout<<XMLString::transcode(value->getTextContent());
cout<<"\n";
value->setTextContent( XMLString::transcode(" next") ); // this will update the element named "value"
}
}
}
}
int main()
{
string configFile="/home/manish.yadav/Desktop/sel.xml";
GetConfig appConfig;
appConfig.readConfigFile(configFile);
return 0;
}
i compiled the program successfully and the program is running correctly it shows the out put like that
first
second
0x1314e50
hi
hello
manish
name
the extra output are becoz i want to check the flow control of program
now my problem is that i used the method value->setTextContent( XMLString::transcode(" next") );
it is not working ;
in my xml file i saw the old value. the value is not changing there what should i do so that the value change in sel.xml file too?
what should i do to change the value in xml file ?
what i 'm doing wrong?
i goggled the matter lot but someone saying i cant make change in xml file .
to change xml file i have to read the content of file and create a new file .
can anybody explain what should i do?
i read the dom Programming guide, api Documentation but nothing substantial.
what is the method or way to read from old xml file and write it to a new file ?
can any body explain with code ?
how to make new xml file using dom c++ parser?