[xml] Basic newbie Q about parsing trees



I have a simple XML data tree that looks like this:

<?xml version="1.0" ?>
<pivot>
   <field>
       <line_0>
               <currentField>103</currentField>
       </line_0>
       <line_1>
               <bearingFrom>0.000</bearingFrom>
               <bearingTo>0.000</bearingTo>
               <auxA>0</auxA>
               <auxB>2</auxB>
               <auxC>4</auxC>
               <auxD>6</auxD>
       </line_1>
       <line_2>
               <bearingFrom>0.000</bearingFrom>
               <bearingTo>0.000</bearingTo>
               <auxA>0</auxA>
               <auxB>0</auxB>
               <auxC>0</auxC>
               <auxD>0</auxD>
       </line_2>
  </field>
</pivot>

The line_X elements can repeat a number of times.

I need to parse this data out to a C array. I've used the tree1.c example to walk the tree and print element names, but how do I print the element values?

Basically, I need to a) fill a C array with values in the tree, and b) fill a tree with values from a C array, as simply as possible. I've been through the examples, but this is the first time I've worked with libxml2 and the API is a bit cryptic at the moment.

Thanks,

--Yan



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