Java XML Reading an XML file from top to bottom -


i want read xml starting top bottom using java. however, don't want use recursive functions because want able jump different element , start reading position.

i've tried using getparent() , indexof() methods (all 3 libraries below have these methods) this, it's gotten messy, because methods don't distinguish between attributes , elements.

i'm sure there must simple way this, after trying dom4j, jdom, , xom, still have not found solution.

[edit] more information:

my friend wants make console text-based game in question/answer type style. instead of hard-coding java, decided try , make read xml file instead, because xml has tree-like style convenient. here example of xml file might like:

<disp>text displayed</disp> <disp>text displayed afterward</disp> <disp>what favorite color?</disp> <question>     <answer name="orange">         <disp>good choice.</disp>         <!-- more questions , stuff -->     </answer>     <default>         <disp>wrong. correct answer orange.</disp>     </default> </question>  

i don't know if taboo use xml pseudo programming language. if has other suggestions feel free give them.

your design , example of declarative programming. should read xml files using xml parser either dom or using sax. since think want revisit nodes suspect need dom (fwiw use xom, xom.nu). 1 of best examples of xml-based declarative programming xslt data , commands xml.

i use model great deal. has advantage data structure can external , can edited.

(note xml needs root element)

but it's gotten messy, because methods don't distinguish between attributes , elements.

all dom or sax tools differentiate between attributes , elements, if there confusion somewhere else.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -