AW: [xml] Combining two xml files.
- From: "Mickautsch, Alfred" <alfred mickautsch schuler-ag com>
- To: <xml gnome org>
- Subject: AW: [xml] Combining two xml files.
- Date: Mon, 2 Aug 2004 11:29:08 +0200
it seems to me that your problem is to be found in your recursive function print_element(), but without the
source it is very hard to tell what it is. Maybe an extra xmlTextWriterEndElement() or so.
Servus -- Alfred
-----Ursprüngliche Nachricht-----
Von: xml-bounces gnome org [mailto:xml-bounces gnome org]Im Auftrag von Manish Padmajan
Gesendet: Montag, 2. August 2004 08:13
An: 'xml gnome org'
Betreff: [xml] Combining two xml files.
Hi All,
I am trying to combine 2 xml files into 1 using libxml library.
This is what I have done.
writer = xmlNewTextWriterFilename(file,0);
rc = xmlTextWriterStartElement(writer,BAD_CAST "root");
doc1 = xmlParseFile(file1);
cur = xmlDocGetRootElement(doc1);
rc = xmlTextWriterStartElement(writer,BAD_CAST "xnlFile1");
print_element(cur,doc1,writer,0); //for parsing through the xml file and writing node name and value. This
function is called recursively.
rc = xmlTextWriterEndElement(writer);
doc2 = xmlParseFile(file2);
cur = xmlDocGetRootElement(doc2);
rc = xmlTextWriterStartElement(writer,BAD_CAST "xnlFile2");
print_element(cur,doc2,writer,0);//for parsing through the xml file and writing node name and value. This
function is called recursively.
rc = xmlTextWriterEndElement(writer);
xmlFreeDoc(doc1);
xmlFreeDoc(doc2);
rc = xmlTextWriterEndElement(writer);
xmlFreeTextWriter(writer);
xmlCleanupParser();
When we see the contents of the final xml file, the 'root' is closed even before the contents of the second
file is copied into the final xml file.
Hence the xml file reports an error.
Is there anything wrong that I am doing. I even tried calling xmlCleanupParser() after parsing each xml file.
But it had no effect.
If only one xml file is parsed and written into the final xml file, no errors are reported.
Any hints in this direction will be really helpful.
Thanks.
with rgds,
pmanish
This message is free from Virus - IMSS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]