Now i wish to call an element of that file and display it.e.g. the username.
After searching seemingly endlessly for a way to do this with the basic java libraries the only answer i seem to get is use an additional open source library. I would prefer to know how to do it with the existing libraries if only for learning sake but eventually giving up on finding reasonable info on doing so i chose XOM as it is used in a book i am using and am now trying figure out how that works and as per usual most 'tutorials' are designed for people who know quite a bit about what their doing, which i obviously don't...
This is about the closest to my current understanding of how it should work
root shows properties as expected, name shows null?
What argument am i meant to give to retrieve that element so the readout would be "rcade"?
Or preferably how do you retrieve it using the basic libraries?
Just as a followup, at least in Java 6 & 7, Java does ship with full DOM, SAX, and StaX libraries. XOM appears to be a DOM implementation, so if you want to continue that route, see this part of the Java Tutorials for how to use the JAXP implementation that is part of standard Java: http://docs.oracle.com/javase/tutorial/jaxp/dom/index.html
Because everything I said in the last paragraph might look like alphabet soup, here is some explanation:
DOM = Document Object Model. It reads an XML file in and stores it in memory in a model that lets you repeatedly navigate through it, and look at parent-child relationships. To me it is the easiest to understand but can be kinda slow or memory intensive for large XML files
SAX = Simple API for XML. It reads the XML file in tag by tag and uses events to callback and tell your application that it reached particular tags or events. Can be efficient because it doesn't hold anything in memory, but is harder to work with because you have to listen for the parts of the XML you want.
StAX = Streaming API for XML. Sort of a combination between DOM and SAX if I understand it. It uses event driven parsing but lets you pill the info from the file, and lets you navigate in both directions.
JAXP = Java API for XML Processing. A particular implementation of these above models for reading XML in Java.
Joined: May 17, 2012
Thanks for all your help Steve.
Initial testing seems to work as required in regard to simply importing from an XML file. As per usual it's knowing which direction to look in is the hard part
I really appreciate the followup and I'll certainly look more into those libraries that ship with java as (for learning purposes at least) i would rather learn with the basic tools first and then maybe move onto external tools once i have the basics figured out in case for some reason in the future i can't use an external tool and i always have the basic tools to fall back on if needs be.