Hi, I am trying to parse below shown XML file using xom parser in java and put each key,value pairs into Map. Later I am trying to insert this Map into Cassandra using Mutator object. My XML file looks like as below: <sample> <Max>0.25000</Max> <test> <A>Percentage</A> <B>1</B> <C>0</C> <D>2000000000</D> <E>0.25</E> </test> <test> <A>Percentage</A> <B>1</B> <C>5000000000</C> <D>7500000000</D> <E>0.15</E> </test> </sample>
Currently I have HashMap<String,String> xmlData to hold elements of XML. I am traversing each child elements using getChildElements() and then retrieving element name ,element value and storing them inside HashMap. But I am facing problem while doing for the second subchild element (<test>marked in green) because it overwrites values of child elements of which I had traversed in my last iteration (<test> marked in blue) . Could somebody provide thoughts on how to store data in Cassandra in above situation. Is there any better way to it or do I need to append counter+xpath. For example, if there are 2 child elements, append <test1>+1+<A> for element <A> inside first <test> and append <test>+2+<A> for subchild of another <test> element. Thanks in advance. Best, Santosh Shet Software Engineer | VistaOne Solutions Direct India : +91 80 30273829 | Mobile India : +91 8105720582 Skype : santushet