Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What's the simplest way to adding an attribute ?  RSS feed

Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!