I am trying to read in and eventually manipulate an 'XML-type' file. I have picked up a hobby called 'Geocaching', some people probably have heard of it, where you use gps coords to locate items placed by other people.
Well, you can download the gps coors within data files from the website,'Geocaching.com' and these files are in a XML format.
There are a lot of programs out there that people offer, some are better than others, but I am not happy with the results. So, I am trying to see how I can use these files myself and create my own program to use the data in a way that I want to use it.
I have tried to use Linq, XMLdocument, XMLreader and probably a couple of others over the past week. I have had marginal sucess with each of these methods, but nothing great and I owe that to my lack of knowledge.
I eventually hope to add the data to a Access db that I am using and manipulate the info from the db.
I am attaching a sample of one of the downloaded files and if someone would have the patience to help me work my way through it, I would be greatful.
Thanks,
Richard
p.s. The file typically ends with '.gpx', but since its an xml and thats what the system recognizes, I added the extension in order to upload the sample file.
Last edited by RichardKnox; Jun 22nd, 2010 at 11:29 AM.
Reason: More info about what I want to do with the info from xml file
Thanks,
Richard -
--------
-->Newbie Coder<<--
Using VB.NET 2008/.NET 2.0/3.5
The long and short of it, is I want to take the data from the 'xml-type' file and insert it into an Access database. Which from there I can manipulate the data for use in my program.
Now, whats the best way to get the data from the xml-type file to the db.
Thanks,
Thanks,
Richard -
--------
-->Newbie Coder<<--
Using VB.NET 2008/.NET 2.0/3.5
generally, for me, it's usually to load the data into an XMLDocument, select out the nodes I'm interested in, and insert them in to the database.
You could also see what happens if you try to import the XML document into Access (don't know if it can handle xml) ... are you looking for a one-time deal? Or something to do this on an ongoing basis?
generally, for me, it's usually to load the data into an XMLDocument, select out the nodes I'm interested in, and insert them in to the database.
You could also see what happens if you try to import the XML document into Access (don't know if it can handle xml) ... are you looking for a one-time deal? Or something to do this on an ongoing basis?
-tg
This is an ongoing basis. Basically what I want to do, is download these files as I find ones on the website for me to search for and import it into my program so that I can keep track on my laptop a bit better than I have been. Thats why I want to import this file into a access db, that way I can keep track of the ones I have already visited and the ones I havent and the ones that I keep having to go back on because I cant find it.
I first tried the xmldocument, but wasnt able to figure out how to select out the nodes and assign them to their respective variable before importing it into the db. I understand the import part into the db, its just getting nodes from the xmldocument.
Thanks,
Richard -
--------
-->Newbie Coder<<--
Using VB.NET 2008/.NET 2.0/3.5
Dim xml_doc as New XmlDocument
xml_doc.Load(filepath)
Dim root as XmlElement = xml_doc.DocumentElement
root would be the top-level node. Called "gpx" in your example file.
root.ChildNodes(0) would be the "name" node, etc. root.ChildNodes(0).innertext would return "Cache Listing Generated from Geocaching.com"
root.childnodes(8).Attributes(0).Value would return the minlat value, and so on.
Using that format, you can get the info you need. I'm guessing the Latitude, Longitude, name, etc.
Is there a chart/page or something online that I could look at to get a better feel for how that works? I know that this is something that is taught in school, but I dont have the time or the money to go that direction.
So I am home schooled. (haha home schooled at 44 years old......)
Thanks,
Richard -
--------
-->Newbie Coder<<--
Using VB.NET 2008/.NET 2.0/3.5
MSDN .... that's going to be your best friend in all this... best way to search is to enter terms in the form {CLASSNAME}.[FUNCTION}..... so in this case your search terms should be xmldocument.documentelement ... and xmlnode.childnode you'll also want to probably look at xmlnode.selectnodes and xmlnode.selectsinglenode.
-tg
side note - I'm 100% self-taught too. I don't do well in classrooms. There's nothing wrong with it. I think you might be surprised at how many of us here fall into that self taught category.
MSDN .... that's going to be your best friend in all this... best way to search is to enter terms in the form {CLASSNAME}.[FUNCTION}..... so in this case your search terms should be xmldocument.documentelement ... and xmlnode.childnode you'll also want to probably look at xmlnode.selectnodes and xmlnode.selectsinglenode.
-tg
side note - I'm 100% self-taught too. I don't do well in classrooms. There's nothing wrong with it. I think you might be surprised at how many of us here fall into that self taught category.
Where did you get most of your information to learn from? Books, online, etc... What books would you suggest? What websites would you suggest?
Thanks,
Richard -
--------
-->Newbie Coder<<--
Using VB.NET 2008/.NET 2.0/3.5
I read... A LOT! I learned to see the difference between books that are reference style - which get used over and over and over, vs tutorial style books - where you read once, do the examples and never read again. There are a few that are in between. MSDN (msdn.microsoft.com) ... like I said, get to know that, it should be your first stop when looking up something, Google second, here third. I don't normally like to recommend things because people learn in different ways... some like to have the code handed to them, others just need to be pointed in the right direction, others can take a sample code and then tailor it to their own needs.
To answer your question, what you could do is a For Each loop....
Code:
For Each mNode As XMLElement In Root.childnodes
Dim Lat = mNode.Attributes("lat").value
Dim Lon = mNode.Attributes("lon").value
'Do what you need to do with Lat/Lon here
Next
NOTE: XML is CASE SENSITIVE ... Lat and LAT and lat are NOT THE SAME THING. Also, I haven't looked at the XML, so I don't know what the proper attribute name is, so you may need to change the lat & lon.
I have a BS in computer science and all we programmed in was Java, C++ and C (except for the occasional fortran/cobal/rpg/etc.. in survey). I don't think many universities actually teach .NET.
Justin
You down with OOP? Yeah you know me!
MCAD and MCMICKEYMOUSE (vb.net)