aspose file tools*
The moose likes Java in General and the fly likes  java xml reading dom metods help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark " java xml reading dom metods help" Watch " java xml reading dom metods help" New topic
Author

java xml reading dom metods help

simon did
Greenhorn

Joined: Dec 18, 2013
Posts: 5
hey i also asked this queston here ;)
http://www.java-forums.org/new-java/84292-java-xml-reading-dom-metods-help.html

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 :


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:

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2627
    
    9

There's a hasAttributes() method in the Node interface.

Then there is a class called Attr



K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

simon did wrote:Below is my currently code where some parts is working but accessing requiredskills, requiredattributes,skillbonusCollection isn’t

What problem are you having? Specifically what input, what output, what is the difference? We can't help if you don't TellTheDetails (<- link).


Not sure, but I am guessing the problem you are having is in the commented code, so you removed the most relevant part of the code: so we can't deduce your problem from your code either.

A couple of hints: your variable names are next to useless. It makes it hard to track what data you expect in each element. If you name them appropriate to the expected data it might be easier to read and work with. As it stands, I find it impossible to figure out what line of code is used to get what line of XML, because the element names are generic, you start at some point that doesn't exist in your example XML ("result") and your variables are repetitive, take the name of the XML tag rather than the data it should represent.

You might consider using XPath to select the proper rows/rowsets for the requiredSkills, etc... For example, assume you have a Node pointing to a <row ...> for a particular skill:


It has been a while, so the XPath and the rest of the code might not be quite right, but it should get you started. See http://docs.oracle.com/javase/tutorial/jaxp/xslt/xpath.html


Steve
simon did
Greenhorn

Joined: Dec 18, 2013
Posts: 5
thanks alot for the replay i goth it working with the code you posted :P

sry if my problem discription was bad

and thanks for making me aware off xpath i think i might change all my code to xpath becouse i think it's simplere :P
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: java xml reading dom metods help