Results 1 to 2 of 2
  1. #1
    simondid is offline Member
    Join Date
    Dec 2013
    Rep Power

    Default java xml reading dom metods help

    hey so i have this giant xml document with a lot off data in

    Iím trying to load this xml document in to a sql database my problem is reading the document :(
    i need to make every skill in to a different row in my db with columns like description,rank,requiredAttributes, requiredSkills, skillBonusCollection my problem is reading the required Skills and skillBonusCollection

    so what i want to do is to make each row off skills
    example :
    Java Code:
    <row typeName="Advanced Planetology" groupID="1241" typeID="2403" published="1">
    The advanced understanding of planet evolution allowing you to interpret data from scans of planets for resources at much higher resolutions. Bonus: The skill further increases the resolution of resource data when scanning a planet to allow for very precise surveying. Note: this skill cannot be trained on trial accounts.
    <rowset name="requiredSkills" key="typeID" columns="typeID,skillLevel">
    <row typeID="2406" skillLevel="4"/>
    <rowset name="skillBonusCollection" key="bonusType" columns="bonusType,bonusValue">
    <row bonusType="canNotBeTrainedOnTrial" bonusValue="1"/>
    Take this and get everything out as different variables

    i already made it work with getting stuff like typename, typeid, description,rank out of the dukoment without errors but in having trouble when i need to acces requiredskills, requiredattributes,skillbonusCollection
    be aware that required skills might not exist

    Below is my currently code where some parts is working but accessing requiredskills, requiredattributes,skillbonusCollection isnít :(

    Java Code:
    	 private String fillSkillDB() throws SAXException, IOException, ParserConfigurationException{
    			File file = new File(MainDir+"/"+skillTreeXMlFileName);
    			int addedSkills =0;
    			SqlDbHelper entry = new SqlDbHelper(myContext);
    			InputStream is;
    				is = new FileInputStream(file.getPath());
    		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    			DocumentBuilder db = dbf.newDocumentBuilder();
    			Document doc = db.parse(new InputSource(is));
    			NodeList rootNodes = doc.getElementsByTagName("eveapi");
    			Node RootNode = rootNodes.item(0);
    			Element rooteElement = (Element) RootNode;
    			NodeList resultNote = rooteElement.getElementsByTagName("result");
    			Node resultnode = resultNote.item(0);
    			Element resultElement = (Element) resultnode;
    				NodeList CurrentNodeList = resultElement.getElementsByTagName("rowset");
    					Node theNotee = CurrentNodeList.item(0);
    					Element noteElement = (Element) theNotee;
    					NodeList rowlist = noteElement.getElementsByTagName("row");
    						for (int k = 0; k < rowlist.getLength(); k++) {
    							Node theNote = rowlist.item(k);
    							Element data = (Element) theNote;
    							if(data.getAttribute("typeID") != "" && data.getAttribute("typeName") != ""){
    								try {
    									Element resultElemente = (Element) data;
    									NodeList rowsetList = resultElemente.getElementsByTagName("rowset");
    									Node rowsetNode = rowsetList.item(0);
    									Element rowserElement = (Element) rowsetNode;
    									NodeList rowset = rowserElement.getElementsByTagName("row");
    									for (int i = 0; i < rowset.getLength(); i++) {
    										Node theNoteee = rowset.item(i);
    										Element noteElemente = (Element) theNoteee;
    										// wanna parse the requiredSkills type id to an array here 
    										// but fore some reason it makes alot off unwanted type id with it 
    												} catch (Exception e) {
    													// TODO: handle exception
    			return null;

  2. #2
    simondid is offline Member
    Join Date
    Dec 2013
    Rep Power

Similar Threads

  1. java GUI , reading in files
    By zerocool1822 in forum New To Java
    Replies: 3
    Last Post: 02-25-2013, 10:39 AM
  2. Reading Java Code x=b(a,b)
    By sezzy in forum New To Java
    Replies: 8
    Last Post: 11-26-2012, 03:00 AM
  3. Replies: 8
    Last Post: 12-14-2011, 01:40 PM
  4. Xml reading in java
    By Keerthana in forum XML
    Replies: 2
    Last Post: 06-08-2010, 02:26 PM
  5. Replies: 5
    Last Post: 08-21-2009, 12:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts