Skip to main content
added 108 characters in body; deleted 1 characters in body; added 39 characters in body
Source Link
John Pickup
  • 5.1k
  • 2
  • 24
  • 16

Your code will repeatedly replace the "Tr" column with your concatenation of tag + " " + value so it'll only be the last one that goes in. Don't you perhaps want the different tags to go in different columns? Or maybe you need to continue concatenating and only call updateString at the end.

Could you post the desired table row for the given XML? That should help in determining what you are trying to achieve.

For example, if you just want to append them:

StringBuffer tr = new StringBuffer();;; while (!myWorkLine.substring(0,1).equals("<")) { myTag = myWorkLine.substring(0,myWorkLine.indexOf("=")); myWorkLine = myWorkLine.substring(myWorkLine.indexOf("=")+2); myValue = myWorkLine.substring(0,myWorkLine.indexOf("\"")); myWorkLine = myWorkLine.substring(myWorkLine.indexOf("\"")+2); tr.append(myTag + " " + myValue).append(","); if (myWorkLine.substring(0,myWorkLine.indexOf("\">")).indexOf(">") > 0) break; } if (tr.length() > 0) { tr.deleteCharAt(tr.length()-1); // get rid of last comma } uprs.updateString("Tr",tr.toString()); 

Your code will repeatedly replace the "Tr" column with your concatenation of tag + " " + value so it'll only be the last one that goes in. Don't you perhaps want the different tags to go in different columns? Or maybe you need to continue concatenating and only call updateString at the end.

Could you post the desired table row for the given XML? That should help in determining what you are trying to achieve.

For example:

StringBuffer tr = new StringBuffer();; while (!myWorkLine.substring(0,1).equals("<")) { myTag = myWorkLine.substring(0,myWorkLine.indexOf("=")); myWorkLine = myWorkLine.substring(myWorkLine.indexOf("=")+2); myValue = myWorkLine.substring(0,myWorkLine.indexOf("\"")); myWorkLine = myWorkLine.substring(myWorkLine.indexOf("\"")+2); tr.append(myTag + " " + myValue); if (myWorkLine.substring(0,myWorkLine.indexOf("\">")).indexOf(">") > 0) break; } uprs.updateString("Tr",tr.toString()); 

Your code will repeatedly replace the "Tr" column with your concatenation of tag + " " + value so it'll only be the last one that goes in. Don't you perhaps want the different tags to go in different columns? Or maybe you need to continue concatenating and only call updateString at the end.

Could you post the desired table row for the given XML? That should help in determining what you are trying to achieve.

For example, if you just want to append them:

StringBuffer tr = new StringBuffer(); while (!myWorkLine.substring(0,1).equals("<")) { myTag = myWorkLine.substring(0,myWorkLine.indexOf("=")); myWorkLine = myWorkLine.substring(myWorkLine.indexOf("=")+2); myValue = myWorkLine.substring(0,myWorkLine.indexOf("\"")); myWorkLine = myWorkLine.substring(myWorkLine.indexOf("\"")+2); tr.append(myTag + " " + myValue).append(","); if (myWorkLine.substring(0,myWorkLine.indexOf("\">")).indexOf(">") > 0) break; } if (tr.length() > 0) { tr.deleteCharAt(tr.length()-1); // get rid of last comma } uprs.updateString("Tr",tr.toString()); 
Source Link
John Pickup
  • 5.1k
  • 2
  • 24
  • 16

Your code will repeatedly replace the "Tr" column with your concatenation of tag + " " + value so it'll only be the last one that goes in. Don't you perhaps want the different tags to go in different columns? Or maybe you need to continue concatenating and only call updateString at the end.

Could you post the desired table row for the given XML? That should help in determining what you are trying to achieve.

For example:

StringBuffer tr = new StringBuffer();; while (!myWorkLine.substring(0,1).equals("<")) { myTag = myWorkLine.substring(0,myWorkLine.indexOf("=")); myWorkLine = myWorkLine.substring(myWorkLine.indexOf("=")+2); myValue = myWorkLine.substring(0,myWorkLine.indexOf("\"")); myWorkLine = myWorkLine.substring(myWorkLine.indexOf("\"")+2); tr.append(myTag + " " + myValue); if (myWorkLine.substring(0,myWorkLine.indexOf("\">")).indexOf(">") > 0) break; } uprs.updateString("Tr",tr.toString());