Click to See Complete Forum and Search --> : Urgent help!(prob with adding a child node to my root element)


magicstar
October 15th, 2003, 09:45 AM
Hi

I have to append a child node to my root element.In fact the xml parser will be reading the stm.xml file and then convert it to a doma n then append it to my global node called m_globalNode.The parsing is being done well.But it is not appending the child node.here is the sample code:

int sample::addRequestTypeFile(RWCString filename,int haveToCheck)
{


Node *newNode = NULL;

ub4 flags;
uword ecode;
flags = XML_FLAG_VALIDATE | XML_FLAG_DISCARD_WHITESPACE;

if (ecode = parser.xmlinit())
cout << "Failed to initialize XML parser, error " << ecode;

cout << "filename :" << filename;

if (ecode = parser.xmlparse((oratext *) filename.data(), (oratext *) 0, flags))

cout << "Failed to initialize XML parser, error " << ecode;

newNode = parser.getDocumentElement();


if (m_globalNode != NULL)
{
if (newNode == NULL)
{
RWCString message = "The xml file not be parsed with success : ";
message += filename;

m_badFilesNames += " ";
m_badFilesNames += filename;
m_nbBadFiles++;
return 1;
}
else
{
m_globalNode->appendChild(newNode);
m_globalNode->print();

}
}
else
{
cout << "Please allocate your sample object." ;
}



}


int main(int argc, char* argv[])
{
sample mm;

RWCString nameoffile;
nameoffile="stm.xml";
mm.addRequestTypeFile(nameoffile,0);
//(mm.getName())->print();
return 0;

}

Plz help.thks


magicstar