Deploying an xml parser in c

I look at creating a simple XML parser with c99, I want to implement every detail for it only for training purposes, from my understanding the best way is to implement a tree structure and tokenize the xml string into a tree structure, it will look something like enter image description here

and I will have two simple structures representing node and one that represents the attribute, how bad is this project?

any suggestions for improvement?

+4
source share
2 answers

The complexity of your chosen task aside, your data structure looks good at first glance, but, in my opinion, there are two or three things wrong:

  • , -,
  • stdribute . .
  • ( node .)

, xml node. , XML:

<dinner time="19:00" dresscode="informal">
    <course id="starter">
        <food>Consomme</food>
        <food>Tomato soup</food>
    <course>
    <course id="salad" optional=optional>
        <food>Green salad</food>
    <course>
    <course id="main">
        <food>Steak and kidney pie</food>
        <food type=vegetarian>Spinach lasagna</food>
    <course>
    <course id="dessert">
        <food>Fruit</food>
        <food>Ice cream</food>
        <food>Coffee</food>
    <course>
</dinner>

food course s, , course . . - , - .

, , . ( left, - right.) .

- , .

(, XML .)

+2

, , . , , , : , ( ) . , . , , (, DOM) (, XPath/XSLT/XQuery).

, XML: ? . CDATA? ? ?

, c99, .

+1
source

Source: https://habr.com/ru/post/1524018/


All Articles