hi all iam new to java and xml and i need suggestion reg this design ..this is wat my input xml going to be <xpTransactions> <transList> <xpTrans name="ADD_AG"> <childTrans>ADD_ED</childTrans> <childTrans>ADD_CD</childTrans> <actionDelay> <timeSec>60<\timeSec> <retry>1<\retry> </actionDelay> </xpTrans> <xpTrans name="ADD_ED"> <actionIntf>add_r</actionIntf> <actionIntf>add_ml</actionIntf> <actionIntf>sub_mlk</actionIntf> </xpTrans> <xpTrans name="ADD_CD"> <actionIntf>add_rkm</actionIntf> <actionIntf>sub_mlcd</actionIntf> <actionIntf>sub_mlki</actionIntf> </xpTrans> </transList> </xpTransactions >
input to the java program will be xpTrans name so for eg when the input is ADD_AG i need to check whether it has any child and if it is then nee to get all the elements underneath it ..so in this case we have two chils elements so the output should be
when the input is goin to be ADD_ED ( this does not have any child so )the output is
ADD_ED add_r add_ml sub_mlk
palnning to use Jdom and create a tree structure and then store each node and its contents in alist ...is this approach corerct .is it is after storing it in a list how do i associate ie check that it has chils or not .
thanks for the help
Joined: Nov 09, 2006
got another doubt is itpossible to build a tree structure with the above xml or should i use JAXP?
You are going to use JDOM? Its entire purpose is to convert the XML document into a tree structure. And it does have methods that you can call to find out whether a node has children or not. I would suggest reading some XML tutorials, and looking at the JDOM site for examples or tutorials, or if it doesn't have any of those then look at the JDOM API documentation.