You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by frofis <fr...@sdm.ru> on 2006/08/25 14:52:57 UTC

write xml

run writeProp all rigth
run writeProp second Access violation - while?




void TRkcXml::writeProp(void)
{
   if (FileExists(fileProp)) {
      bool write = false;
      XercesDOMParser *prop = new XercesDOMParser;
      ErrorRep *errRep = new ErrorRep();
      prop->setErrorHandler(errRep);
      XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDoc = 0;
      try {
         prop->parse(fileProp);
         pDoc = prop->getDocument();
         if (writeValue(pDoc->getDocumentElement(), "pathxsd", "value", 
fProp->deDirXsd->Text))
            write = true;
         if(writeValue(pDoc->getDocumentElement(), "pathinp", "value", 
fProp->deDirInp->Text))
            write = true;
         if(writeValue(pDoc->getDocumentElement(), "pathinpsave", 
"value", fProp->deDirInpSave->Text))
            write = true;
         if(writeValue(pDoc->getDocumentElement(), "pathinparhiv", 
"value", fProp->deDirInpArhiv->Text))
            write = true;
         if(writeValue(pDoc->getDocumentElement(), "bic", "value", 
fProp->meBIC->Text))
            write = true;
         if(writeValue(pDoc->getDocumentElement(), "bicrkc", "value", 
fProp->meBICRKC->Text))
            write = true;
         if (write)
            writeDocProp(pDoc, fileProp);
      }
      catch (...) {
         ShowMessage("...");
      }
      delete errRep;
      delete prop;
      //delete
      //pDoc->release();
   }
}

void TRkcXml::writeDocProp(DOMDocument *docWrite, WideString pathDocWrite)
{
   LocalFileFormatTarget* pXMLfile;
   DOMImplementation* impl = 
DOMImplementationRegistry::getDOMImplementation(L"LS");
   DOMWriter* writer = ((DOMImplementationLS*)impl)->createDOMWriter();
   pXMLfile = new LocalFileFormatTarget(fileProp);
   writer->writeNode(pXMLfile, *docWrite);
   delete pXMLfile;
   writer->release();
   delete impl;
}


Re: write xml

Posted by Alberto Massari <am...@datadirect.com>.
At 12.52 25/08/2006 +0000, frofis wrote:
>run writeProp all rigth
>run writeProp second Access violation - while?
>
>[...]
>void TRkcXml::writeDocProp(DOMDocument *docWrite, WideString pathDocWrite)
>{
>    LocalFileFormatTarget* pXMLfile;
>    DOMImplementation* impl =
>DOMImplementationRegistry::getDOMImplementation(L"LS");
>    DOMWriter* writer = ((DOMImplementationLS*)impl)->createDOMWriter();
>    pXMLfile = new LocalFileFormatTarget(fileProp);
>    writer->writeNode(pXMLfile, *docWrite);
>    delete pXMLfile;
>    writer->release();

********************
>    delete impl;
********************

You should not delete the DOMImplementation*, as it is a static object.

Alberto