If you are more interested in creating the output than learning to code
with libxml2, you may want to use xslt to convert your input XML
document into your desired output.
Xsltproc is one of executables you can use for such transformations:
http://xmlsoft.org/XSLT/xsltproc.html

> -----Original Message-----
> From: David Kinyanjui [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 17, 2006 7:01 PM
> To: [email protected]
> Subject: [xml] parsing xml file using xmlTextReader
> 
> Hello everyone;
> I'm trying to extract data from a xml file and use it
> for a report... I
> have just come across xmlTextReader.
> I'm hoping to parse/extract the values/counts for
> (date, currdollar,
> gender) and load it into a map.
> I'm thinking the key for the map can be the dates'
> value/count then the
> value for the map can be the a structure of two vector
> (one contain the
> currdollar and another for gender).
> In other words, the data will need to be grouped by
> date and currdollar
> as you may notice on the sample output.
> Then I can use this map to display the data in
> different forms.
> 
> Thanks in advance your asssitance.
> 
> The following is an xml and output samples:
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <dps:services xmlns:dps="uri">
> <dps:output>
> 
> <dps:tally dps:name="test_1">
>   <dps:tally dps:name="date">
>     <dps:tally dps:name="currdollar">
>       <dps:tally dps:name="Gender">
>         <dps:value>U</dps:value>
>         <dps:count>4</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>M</dps:value>
>         <dps:count>57</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>I</dps:value>
>         <dps:count>5</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>F</dps:value>
>         <dps:count>220</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>C</dps:value>
>         <dps:count>1</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>A</dps:value>
>         <dps:count>18</dps:count>
>       </dps:tally>
>       <dps:value>000-005</dps:value>
>       <dps:count>305</dps:count>
>     </dps:tally>
>     <dps:tally dps:name="currdollar">
>       <dps:tally dps:name="Gender">
>         <dps:value>U</dps:value>
>         <dps:count>18</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>M</dps:value>
>         <dps:count>82</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>I</dps:value>
>         <dps:count>14</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>F</dps:value>
>         <dps:count>330</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>C</dps:value>
>         <dps:count>1</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>A</dps:value>
>         <dps:count>33</dps:count>
>       </dps:tally>
> 
> 
>       <dps:value>005-010</dps:value>
>       <dps:count>478</dps:count>
>     </dps:tally>
>     <dps:tally dps:name="currdollar">
>       <dps:tally dps:name="Gender">
>         <dps:value>U</dps:value>
>         <dps:count>20</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>M</dps:value>
>         <dps:count>109</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>I</dps:value>
>         <dps:count>25</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>F</dps:value>
>         <dps:count>490</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>C</dps:value>
>         <dps:count>6</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>B</dps:value>
>         <dps:count>1</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>A</dps:value>
>         <dps:count>56</dps:count>
>       </dps:tally>
>       <dps:value>010-015</dps:value>
>       <dps:count>707</dps:count>
>     </dps:tally>
>     <dps:tally dps:name="currdollar">
>       <dps:tally dps:name="Gender">
>         <dps:value>U</dps:value>
>         <dps:count>8</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>M</dps:value>
>         <dps:count>34</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>I</dps:value>
>         <dps:count>3</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>F</dps:value>
>         <dps:count>160</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>C</dps:value>
>         <dps:count>1</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>A</dps:value>
> 
> 
> 
>         <dps:count>13</dps:count>
>       </dps:tally>
>       <dps:value>015-020</dps:value>
>       <dps:count>219</dps:count>
>     </dps:tally>
>     <dps:tally dps:name="currdollar">
>       <dps:tally dps:name="Gender">
>         <dps:value>U</dps:value>
>         <dps:count>30</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>M</dps:value>
>         <dps:count>131</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>I</dps:value>
>         <dps:count>17</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>F</dps:value>
>         <dps:count>683</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>C</dps:value>
>         <dps:count>6</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>A</dps:value>
>         <dps:count>74</dps:count>
>       </dps:tally>
>       <dps:value>020-025</dps:value>
>       <dps:count>941</dps:count>
>     </dps:tally>
>     <dps:tally dps:name="currdollar">
>       <dps:tally dps:name="Gender">
>         <dps:value>U</dps:value>
>         <dps:count>12</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>M</dps:value>
>         <dps:count>84</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>I</dps:value>
>         <dps:count>5</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>F</dps:value>
>         <dps:count>251</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>C</dps:value>
>         <dps:count>4</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>B</dps:value>
>         <dps:count>1</dps:count>
>       </dps:tally>
>       <dps:tally
> dps:name="Gender">
> 
> 
> 
>         <dps:value>A</dps:value>
>         <dps:count>20</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>7</dps:value>
>         <dps:count>1</dps:count>
>       </dps:tally>
>       <dps:value>025-050</dps:value>
>       <dps:count>378</dps:count>
>     </dps:tally>
>     <dps:tally dps:name="currdollar">
>       <dps:tally dps:name="Gender">
>         <dps:value>U</dps:value>
>         <dps:count>2</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>M</dps:value>
>         <dps:count>18</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>I</dps:value>
>         <dps:count>1</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>F</dps:value>
>         <dps:count>59</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>A</dps:value>
>         <dps:count>9</dps:count>
>       </dps:tally>
>       <dps:value>050-075</dps:value>
>       <dps:count>89</dps:count>
>     </dps:tally>
>     <dps:tally dps:name="currdollar">
>       <dps:tally dps:name="Gender">
>         <dps:value>F</dps:value>
>         <dps:count>5</dps:count>
>       </dps:tally>
>       <dps:value>075-100</dps:value>
>       <dps:count>5</dps:count>
>     </dps:tally>
>     <dps:value>200602</dps:value>
>     <dps:count>3122</dps:count>
>   </dps:tally>
>   <dps:tally dps:name="date">
>     <dps:tally dps:name="currdollar">
>       <dps:tally dps:name="Gender">
>         <dps:value>U</dps:value>
>         <dps:count>6</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>M</dps:value>
>         <dps:count>37</dps:count>
>       </dps:tally>
>       <dps:tally dps:name="Gender">
>         <dps:value>I</dps:value>
>         <dps:count>4</dps:count>
>       </dps:tally>
>       .
> 
> 
> 
> .
>       .
>       .
>   </dps:tally>
> </dps:tally>
> 
> </dps:output>
> </dps:services>
> 
> output sample:
> 200602,3122,000-005,305,U,4
> 200602,3122,000-005,305,M,57
> 200602,3122,000-005,305,I,5
> 200602,3122,000-005,305,F,220
> 200602,3122,000-005,305,C,1
> 200602,3122,000-005,305,A,18
> 200602,3122,005-010,478,U,18
> 200602,3122,005-010,478,M,82
> 200602,3122,005-010,478,I,14
> 200602,3122,005-010,478,F,330
> 200602,3122,005-010,478,C,1
> 200602,3122,005-010,478,A,33
> 200602,3122,010-015,707,U,20
> 200602,3122,010-015,707,M,109
> 200602,3122,010-015,707,I,25
> 200602,3122,010-015,707,F,490
> 200602,3122,010-015,707,C,6
> 200602,3122,010-015,707,B,1
> 200602,3122,010-015,707,A,56
> 200602,3122,015-020,219,U,8
> 200602,3122,015-020,219,M,34
> 200602,3122,015-020,219,I,3
> 200602,3122,015-020,219,F,160
> 200602,3122,015-020,219,C,1
> 200602,3122,015-020,219,A,13
> 200602,3122,020-025,941,U,30
> 200602,3122,020-025,941,M,131
> 200602,3122,020-025,941,I,17
> 200602,3122,020-025,941,F,683
> 200602,3122,020-025,941,C,6
> 200602,3122,020-025,941,A,74
> .
> .
> .
> 200602,3122,075-100,26,U,1
> 200602,3122,075-100,26,M,7
> 200602,3122,075-100,26,I,2
> 200602,3122,075-100,26,F,11
> 200602,3122,075-100,26,A,5
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to