Xml data analysis

closed account (jvoiNwbp)
Hello there everyone. I'm quite new to c++ and I was wondering if I could get your help with how to go about starting some code.
What I have is an xml file that is full of data in this structure:

<node id="31102730" visible="true" version="1" changeset="121396" timestamp="2007-07-01T03:07:26Z" user="rtdg" uid="5168" lat="43.2534931" lon="-79.8709026"/>
<node id="31102725" visible="true" version="4" changeset="10516269" timestamp="2012-01-27T22:56:50Z" user="a_white" uid="583595" lat="43.2522727" lon="-79.8663527"/> etc...

what I need to go about doing is write some code that can identify how many nodes there are in the file and store their respective IDs, latitude, and longitude.

I haven't the slightest clue as to how I can go about collecting this data.... so any help is appreciated!
libxml++ aparrently parses data in an xml file, so you might want to look into that (i havent used it though so idk.)

what i would do is read in each character from the file, and then if you hit < you know you are in a tag (xml calls them tags like html right?) then just read until the last > (careful to makesure you arent reading one in a quote). then sort it into fiels by whitespace, and you should be able to get a list of all of the nodes

edit: if you havent figured anything out by tonite ill show you an example of what i mean
Last edited on
closed account (jvoiNwbp)
I'm much more comfortable in python, in which case I'd make a list of lists to separate the whole text into lines and then those lines into words. Then just check for where the list[i][0] == "<node" to count how many nodes there are and then sort data that way. I have no clue if that is the correct way to go about it in c++ or if there is an easier way.
closed account (jvoiNwbp)
Little Bobby Tables: If at some point today you could give an example, that would be amazing! :P
sure. ill write something up
Topic archived. No new replies allowed.