Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's the simplest way to adding an attribute ?

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I currently have a String with this value:
String s = "<item xsi:type=\"xsd:string\">hello</item>";
Now I want to add an attribute like this:
<item soap-enc :position="[1]" xsi:type="xsd:string" >hello</item>
What's is the simplest way to do this ?
The element name "item" is variable. So trying to do a string
replace over "<item " with "soap-enc :position=\"[1]\"" will
not work all the time.
I do not specifically prefer a DOM/SAX solution; even
a simple string manipulation is fine with me.
Thanks for answering.
Pho
[This message has been edited by Ajith Kallambella (edited August 01, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic