The code is incomplete. For one thing, there's no code for PrepareDocumentTree(). For another, xmlDoc is never initialized. Still, a couple of possible problems stand out.
First, you shouldn't just ignore an initialization failure. If XMLPlatformUtils::Initialize() fails, you should assume that all Xerces calls will fail. Make sure you're performing initialization and termination as described in the programming guide link I sent earlier. Second, you appear to have two documents (m_xmlDoc and xmlDoc). Is that intentional? I suspect that your serialized document has no MyString element because you sometimes use one document, sometimes the other. -----Original Message----- From: K.WIKI [mailto:kgou...@gmail.com] Sent: Thu 6/25/2009 9:59 AM To: c-users@xerces.apache.org Subject: RE: Xerces and special caractere < > Thanks for responses now I wrote what I do Exactly int CMMPCreaXMLRecCmd::CreaXML() { try { XMLPlatformUtils::Initialize(); } catch(const XMLException& ) { } XMLString::transcode("LS", xmlChTemp, (LENGTH - 1)); xmlImpl = DOMImplementationRegistry::getDOMImplementation(xmlChTemp); PrepareDocumentTree(); try { DOMWriter *theSerializer = ((DOMImplementationLS*)xmlImpl)->createDOMWriter(); DOMErrorHandler *errorHandler = new DOMCountErrorHandler(); theSerializer->setErrorHandler(errorHandler); if (theSerializer->canSetFeature(XMLUni::fgDOMWRTSplitCdataSections, false)) theSerializer->setFeature(XMLUni::fgDOMWRTSplitCdataSections, false); if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent, false)) theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, false); if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true)) theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true); if (theSerializer->canSetFeature(XMLUni::fgDOMWRTBOM, true)) theSerializer->setFeature(XMLUni::fgDOMWRTBOM, true); XMLFormatTarget *FormTarget = new LocalFileFormatTarget(strFile); theSerializer->writeNode(FormTarget, *xmlDoc); theSerializer->release(); delete errorHandler; delete FormTarget; } catch (const OutOfMemoryException& /*e*/) { } catch (const XMLException& /*e*/) { } xmlDoc->release(); } void CMMPCreaXMLRecCmd::DocumentTree() { XMLCh tempStr[LENGTH_TEMPORAL_STRING_3]; CString strNomRuta = "MyString"; XMLString::transcode(strNomRuta, xmlChTemp, (LENGTH_TEMPORAL_STRING_3 - 1)); m_xmlDoc = xmlImpl->createDocument(0, xmlChTemp, 0); DOMElement* MyString = xmlDoc->getDocumentElement(); XMLString::transcode("version", xmlChTemp, (LENGTH_TEMPORAL_STRING_3 - 1)); XMLString::transcode(VERSIO_XML_REC_CMD, tempStr, (LENGTH_TEMPORAL_STRING_3 - 1)); DOMAttr* attr = xmlDoc->createAttribute(xmlChTemp); attr->setValue(tempStr); MyString->setAttributeNode(attr); XMLString::transcode(strValue, xmlChTemp, (LENGTH_TEMPORAL_STRING_3 - 1)); DOMText* textNode = xmlDoc->createTextNode(xmlChTemp); MyString->appendChild(textNode); } And strValue content is like this <Personne><FirstName>toto</FirstName><LastName>toto</LastName></Personne><Personne><FirstName>tata</FirstName><LastName>tata</LastName></Personne> in resultat I want a file Like that <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <MyString version="2.0"> <Personne> <FirstName>toto</FirstName> <LastName>toto</LastName> </Personne> <Personne> <FirstName>tata</FirstName> <LastName>tata</LastName> </Personne> </MyString > So when i transcode this string , the caractere < change to "& l t ;" there is anu methode to escape the transcoder this caracteres Sorry for My English :-( -- View this message in context: http://www.nabble.com/Xerces-and-special-caractere-%3C-%3E-tp24201194p24203768.html Sent from the Xerces - C - Users mailing list archive at Nabble.com.