[xml] Extracting multiple XML fragments of the same type



Hi!

In my XML file, there are repeating structures that I would like to
extract individually. In the excerpt shown below, these are the fragments
denoted by <Document> elements. I would like to store each of those
<Document>s (and its contents) in a separate xmlDoc. What I got up to now
is:

if ( xmlBuff == NULL ) {
  xmlBuff = xmlBufferCreate();
}
if ( xmlBuff != NULL ) {
  xmlNodeDump( xmlBuff,
               doc,
               curNode,
               0,
               1 );
}

This works nicely for outputting the first of those 3 <Document>s
(since curNode points to the <Document> element. Is there a way to easily
create a new xmlDoc from an existing xmlBuffer? Or is it better to use a
function other than xmlNodeDump for what I am trying to achieve?

My XML input file roughly looks like this

<?xml version="1.0" encoding="iso-8859-1" ?>
[introductory stuff omitted]
<xql:result>
  <Document
   ino:id="1" docId="19970204082505302801" version="1"
   docType="Lieferschein" lastChange="2002-07-15">
     [remaining content omitted]
  </Document>
  <Document
    ino:id="2" docId="19970204082454549313" version="1"
    docType="Lieferschein" lastChange="2002-07-15">
    [remaining content omitted]
  </Document>
  <Document
    ino:id="3" docId="19970204082517775151" version="1"
    docType="Lieferschein" lastChange="2002-07-15">
    [remaining content omitted]
  </Document>
</xql:result>

Thanks in advance for any info!

Greetings,

        Holger





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]