Hi Andrei,//parse problem
Curiously, when I use Xerces DOMParser for parse a XML file, I can save
it or print it with DOMWriter, the accentuated characters are quite
present but if I reach the nodes, I don't have any more accents.
Good; so the parser is evidently doing the right thing. That is, the
information must be available to the parser if it's capable of serializing
it correctly. So the question becomes: how are you "reaching" the nodes
and, as importantly, how are you displaying the result?
//it is necessary to add to what follows the management of the exceptions
XercesDOMParser * parser = new XercesDOMParser;
parser->parse(xml_file_name);
XMLCh * tempStr [100];
DOMDocument * document = parser->getDocument();
XMLString::transcode("*", (XMLCh *) tempStr, 99);
DOMNodeList * laListe = document->getElementsByTagName((const XMLCh*)tempStr);
DOMNode * noeud_courant;
for(XMLSize_t i = 0; i < laListe->getLength(); i++)
{
noeud_courant = laListe->item(i);
//on ne peut pas utiliser tempStr car la taille du contenu peur źtre superieur ą 99
char * une_fuite_de_memoire_colmate = XMLString::transcode(noeud_courant->getNodeName());
String nom_courant (une_fuite_de_memoire_colmate);
delete [] une_fuite_de_memoire_colmate;
String * contenu_courant = XML::getTextContent(noeud_courant);
//I lost the contents
}
/*!
return "char*" of the text content of the node node
*/
String * XML::getTextContent(DOMNode * node)
{
String * res = new String("");
DOMNodeList * laListe = node->getChildNodes();
DOMNode * noeud_courant;
for(XMLSize_t i = 0; i < laListe->getLength(); i++)
{
noeud_courant = laListe->item(i);
// NodeType
switch(/*(DOMNode::NodeType)*/noeud_courant->getNodeType())
{
case DOMNode::ELEMENT_NODE:
{
printf("ELEMENT_NODE ");
String * tampon = getTextContent(noeud_courant);
*res += *tampon;
delete tampon;
break;
}
case DOMNode::ATTRIBUTE_NODE:
//pas de contenu texte ...
break;
case DOMNode::TEXT_NODE:
{
char * tampon = XMLString::transcode(noeud_courant->getNodeValue());
printf("tampon = '%s'\n", tampon);
if(tampon != NULL)
*res += String(tampon);
delete [] tampon;
break;
}
case DOMNode::CDATA_SECTION_NODE:
case DOMNode::ENTITY_REFERENCE_NODE:
case DOMNode::ENTITY_NODE:
case DOMNode::PROCESSING_INSTRUCTION_NODE:
case DOMNode::COMMENT_NODE:
case DOMNode::DOCUMENT_NODE:
case DOMNode::DOCUMENT_TYPE_NODE:
case DOMNode::DOCUMENT_FRAGMENT_NODE:
case DOMNode::NOTATION_NODE:
default :
printf("oups. %d node\n", noeud_courant->getNodeType());
break;
}
}
return res;
}
Do I have errors in the code?
-- Andreļ V. FOMITCHEV [Quand faut-il arrźter l'informatique] Software R&D Engineer [Lorsque, dans un kilo, on trouve 1024 grammes] Odixion, FRANCE
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]