[Expat-discuss] parsing XML

Roman Mashak romez777 at gmail.com
Mon Aug 20 04:28:36 CEST 2007


Hello,

I need to parse out in C language the XML of the following structure:

<BERTEST>
   <NODE1>
      <FREQ>666000000</FREQ>
      <POWER>-82</POWER>
   </NODE1>
   <NODE1>
      <FREQ>484000000</FREQ>
      <POWER>-80</POWER>
   </NODE2>
</BERTEST>

So I took the 'expat' library to do that (I've never dealt with XML before
though), and tried to cutomize the example they ship with library
(outline.c). What I can't quite understand is:
1) is my XML really can be called XML, or it's some sort of invalid?
According to wikipedia page on XML, the valid document should look like
this:

<name attribute="value">content</name>

while mine is a bit different

2) if anyway my xml document is correct, then how can I parse it with expat?
What I need is upon occurences of FREQ and POWER tags to extract their
values (i.e. 666000000 for FREQ or 082 for POWER in the above example).

So, I think I need to register callback function for start tags and try to
do what I want in there. But how can I get the values of tags, which 'expat'
functions to use? Or there's another, more simple way?

Thanks in advance.

-- 
Roman


More information about the Expat-discuss mailing list