-1

i have this following schema

<dataset>
   <record>
      <A> </A>
      <B> </B>
   </record>

   <record>
      <A> </A>
      <B> </B>
   </record>
</dataset>

Can you suggest an efficient algorithm to parse the 'record's and store them in a c structure?

Straightforward parsing is taking a long time as the number of records is around 1500. Any changes to be made in the schema are also welcome.

2 Answers2

0

I suggest not re-inventing an algorithm and using an XML-parser instead. For reasons check this masterly answer on why not to use RegEx on XHTML: RegEx match open tags except XHTML self-contained tags (I admit parsing XHTML is even harder, but things like occasional occuring attributes are the same and the accepted answer is really worth reading)

Community
  • 1
  • 1
Andreas
  • 1,220
  • 8
  • 21
0

You are concerned about runtime - are you on an embedded device? If so you could preprocess the xml into a format that is easy to parse on the microcontroller.

Dill
  • 1,943
  • 4
  • 20
  • 28