inserting values in XPATH while looping around a HAshMap

Hi,

I have a method called setValueOfXPath in my class XMLUtils that is a generic function for XPATH on setting Attributes, it looks like:

publicstatic String setValueOfXPath(String xml, String xPath, String attribute, String value){

basically you can change the attribute value of a certain element by using this function.

Anyway, I have a HashMap that has key-values pairs that I must loop around and get into my XML, I'm trying the code below, but it isn't working - has anyone any ideas?

Set entries = endorsementMap.entrySet();

Iterator iterator = entries.iterator();

int value = 0;

while (iterator.hasNext()){

System.err.println("looping.......");

Map.Entry entry = (Map.Entry)iterator.next();

value = Integer.parseInt(entry.getValue().toString());

response = XMLUtils.setValueOfXPath(response,"//Endorsement[" + value +"]","Info", entry.getKey().toString());

}

it just fails to even execute the response line.

[1330 byte] By [adunkey10a] at [2007-11-27 2:27:41]
# 1
Could it be that the toString method returns a non-parseable string that results in a NumberFormatException?Edit: What's the type of values in your map? Do you really need to convert it into int before printing it?Message was edited by: Peetzore
Peetzorea at 2007-7-12 2:38:43 > top of Java-index,Java Essentials,Java Programming...
# 2
I don't think so, the program just stops and doesn't even enter the line - I've run it in debug mode - I think there's something wrong with the "//Endorsement[" + i + "]" because even if I default that to 0, it doesn't work!
adunkey10a at 2007-7-12 2:38:43 > top of Java-index,Java Essentials,Java Programming...
# 3
You say it doesn't enter the line "response = ..." so that's not where your problem is, if you ask me. Try to give a little more info. Where exactly do you get? do your variables get values? Can you fill us in on the type of values in the map?
Peetzorea at 2007-7-12 2:38:43 > top of Java-index,Java Essentials,Java Programming...