Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

XML parser in C++ - HELP


ghost's Avatar
0 0

i am trying to program a simple xml parser so that i know how to make a bigger one.

the xml file will look like:

<BEGIN>
<NAME>john doe</NAME>
<AGE>22</AGE>
</BEGIN>

as you can see it is really small and is only for practice. The problem is i cant seem to figure out how to parse the file and then test it against the tags and then move the information into a variable to print. Could someone please help me by giving me a quick over view with some suedo-code and maybe a link to a small XML parser source code. or just PM with the cmparing loop please. thanks also no MS VC++. and no XML API like xerces either…just plain C/C++.


spyware's Avatar
Banned
0 0

The problem is i cant seem to figure out how to parse the file and then test it against the tags and then move the information into a variable to print.

Woohoo, slow down there, little fellow. Little problems–>easy solutions.

You want to break this thing down in little steps. Here's what you do: First, you make a list of all the things that need to be done. Remember: LITTLE PROBLEMS–>EASY SOLUTIONS. We need to know exactly where your roadblock is.

If you have a list, code it. Just code until you can't continue, then you try to help yourself using google, or any other library full of information.

If you still can't find your solution, post here.


ghost's Avatar
0 0

i have looked through google quite a bit….i have looked up parsing xml with c/c++. parsing text files, and various different ones. But all i keep getting is xerces but i want to write a program without an API.

i know how to open and read lines from text files but the problem that i have is forming a loop that goes through each character and then looks for the opening bracket "<"m then untill te end bracket ">" pput the info into a tag variable, then after that put the actuall information into a data variable until the ending tag starts which then puts it into the tag variable again. i will then have it compare to an array of tags: markupchar tag_list[] = { &quot;BEGIN&quot;, &quot;NAME&quot;, &quot;AGE&quot;, &quot;&#92;AGE&quot;, &quot;&#92;NAME&quot;, &quot;&#92;BEGIN&quot; }; using a loop that goes through the tags and strcmp to the tag variable. but i just cant seem t figure out how to get it to loop properly without stopping,