M
mathieu
Hi there,
I am struggling to write a piece of code that would parse a simple
xml file. I was wondering if there are good example (pattern?) to use
when dealing with nested xml elements.
For instance my xml looks like (*), with only one level of nesting.
AFAIK I need to do the book keeping myself esp. when reading the
CharacterData so that it is associated to the correct entry.
All I need to do is load the dict in some kind of matching C++
structure. This is not my homework, I am simply trying to use some
kind of pattern so that my code is readable later on.
Thanks
-Mathieu
(*)
<?xml version="1.0"?>
<dict>
<entry key="1" value="a">
<desc>blue</desc>
</entry>
<entry key="2" value="b">
<desc>red</desc>
</entry>
<entry key="3" value="c">
<desc>green</desc>
<entry key="2" value="d">
<desc>purple</desc>
</entry>
<entry key="4" value="e">
<desc>yellow</desc>
</entry>
<entry key="5" value="f">
<desc>orange</desc>
</entry>
</entry>
</dict>
I am struggling to write a piece of code that would parse a simple
xml file. I was wondering if there are good example (pattern?) to use
when dealing with nested xml elements.
For instance my xml looks like (*), with only one level of nesting.
AFAIK I need to do the book keeping myself esp. when reading the
CharacterData so that it is associated to the correct entry.
All I need to do is load the dict in some kind of matching C++
structure. This is not my homework, I am simply trying to use some
kind of pattern so that my code is readable later on.
Thanks
-Mathieu
(*)
<?xml version="1.0"?>
<dict>
<entry key="1" value="a">
<desc>blue</desc>
</entry>
<entry key="2" value="b">
<desc>red</desc>
</entry>
<entry key="3" value="c">
<desc>green</desc>
<entry key="2" value="d">
<desc>purple</desc>
</entry>
<entry key="4" value="e">
<desc>yellow</desc>
</entry>
<entry key="5" value="f">
<desc>orange</desc>
</entry>
</entry>
</dict>