Zapo, cursor.getName() returns the name of the current token. You need to make sure you move the cursor on the right element to get the text and move back to the parent "Testcase" and call toNextSibling().
> -----Original Message----- > From: Zapo [mailto:[EMAIL PROTECTED] > Sent: Tuesday, December 11, 2007 5:17 PM > To: [email protected] > Subject: Using cursor to ierate and adding to map > > > Greetings, > > I am trying to iterate a XML using cursor and then adding to MAP. > The XML has repetable nodes for example > > <Testcase> > <Security>https</Security> > <Server>staging</Server> > </Testcase> > <Testcase> > <Security>https</Security> > <Server>baijing</Server> > </Testcase> > </Testcases> > > I have an array of TestCase objects ready, how to iterate and add to a Map > or Array > > I tried the following way and it did not get too further..I seem to be > missing the usage of cursor and addin to a MAP, I seem to overwrite my MAP > (which I should avoid), > > private static void addtoMap(Testcase item2, int i, > LinkedHashMap<String, String> linkedHashMap) { > > XmlCursor cursor = item.newCursor(); > //Iterate throught the nodes > > cursor.toChild(0); > String name = cursor.getName().toString(); > String value = cursor.getTextValue(); > > //Add to Map > linkedHashMap.put(name, value); > > //Next Sibling > cursor.toNextSibling(); > > String name1 = cursor.getName().toString(); > String value1 = cursor.getTextValue(); > > //Add to Map again > linkedHashMap.put(name, value); > > > System.out.println("Type of Token is: " + > cursor.currentTokenType() + > "\nText of Token is" + cursor.xmlText()); > //} > cursor.dispose(); > > } > > > > > > > -- > View this message in context: http://www.nabble.com/Using-cursor-to- > ierate-and-adding-to-map-tp14285663p14285663.html > Sent from the Xml Beans - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

