I've written a twitter desktop app that basically just lets me post tweets and pics... nothing fancy.
I've got everything working but this last part of persisting a config file (which is the following XML generated by my application.
<?xml version="1.0" encoding="UTF-8" standalone="no"?><Twitterer><config id="1"><accessToken>ENDLESS-STRING-OF-CHARACTERS</accessToken><accessTokenSecret>ANOTHER-ENDLESS-STRING-OF-CHARACTERS</accessTokenSecret></config></Twitterer>
What I need to do is just set the accessToken & accessTokenSecret variables. The filename is config.xml.
I've been looking at a lot of examples on the net, but can't seem to wrap my head around only getting two values from the file, which shouldn't need a loop.
This is as far as I've gotten on this last piece of my puzzle:
try {
File fXmlFile = new File(this.getFileName());
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("config");
int numberOfConfigs = nList.getLength();
// GET THE TWO VARIABLES HERE
} catch (Exception e) {
}
If anyone can help me just read those two tags into their corresponding variables I would be quite appreciative. I can handle the rest of the Authorization after that.
No comments:
Post a Comment