This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes What's the simplest way to adding an attribute ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "What Watch "What New topic

What's the simplest way to adding an attribute ?

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 776

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.
[This message has been edited by Ajith Kallambella (edited August 01, 2001).]


I agree. Here's the link:
subject: What's the simplest way to adding an attribute ?
It's not a secret anymore!