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]