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

    Default java xml reading dom metods help

    hey so i have this giant xml document with a lot off data in
    https://api.eveonline.com/eve/SkillTree.xml.aspx

    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">
    <description>
    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.
    </description>
    <rank>5</rank>
    <rowset name="requiredSkills" key="typeID" columns="typeID,skillLevel">
    <row typeID="2406" skillLevel="4"/>
    </rowset>
    <requiredAttributes>
    <secondaryAttribute>memory</secondaryAttribute>
    <primaryAttribute>intelligence</primaryAttribute>
    </requiredAttributes>
    <rowset name="skillBonusCollection" key="bonusType" columns="bonusType,bonusValue">
    <row bonusType="canNotBeTrainedOnTrial" bonusValue="1"/>
    </rowset>
    </row>
    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);
    			
    			entry.open();
    			
    			InputStream is;
    			
    				is = new FileInputStream(file.getPath());
    			
    		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    			DocumentBuilder db = dbf.newDocumentBuilder();
    			Document doc = db.parse(new InputSource(is));
    			doc.getDocumentElement().normalize();
    			
    			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 
    										//////////////////////////////////////////////////////
    										
    									}
    
    														
    													
    
    												entry.createEntry(
    														data.getAttribute("typeID"),
    														data.getAttribute("typeName"),
    														data.getElementsByTagName("description").item(0).getTextContent().toString(),
    														data.getElementsByTagName("rank").item(0).getTextContent().toString());
    										
    									
    												} catch (Exception e) {
    													// TODO: handle exception
    												}finally{
    
    													addedSkills++;
    													
    												}
    							}
    					}
    
    
    						entry.close();
    			return null;
    		}

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

Similar Threads

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

Posting Permissions

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