{"id":3625,"date":"2010-11-25T21:49:00","date_gmt":"2010-11-25T21:49:00","guid":{"rendered":""},"modified":"2026-04-18T22:52:45","modified_gmt":"2026-04-18T22:52:45","slug":"changing-xml-attributes-using-python","status":"publish","type":"post","link":"https:\/\/hellem.org\/wblog\/?p=3625","title":{"rendered":"Changing XML attributes using Python"},"content":{"rendered":"<p>Doing some work trying to update J2C resources defined in WebSphere using Rational Automation Framework, actually about the same thing as described in the article &#8220;<a href=\"http:\/\/www.ibm.com\/developerworks\/rational\/library\/10\/automatedeploymentapplicationframeworkwebsphere-part2\/index.html\">A step-by-step guide to automating the deployment of a data source by using Rational Build Forge<\/a>&#8221; and I needed to do some changes in jaas.xml. Won&#8217;t go into the details why editing XML using for instance &#8220;normal&#8221; Perl is hard, but I ended up using <a href=\"http:\/\/docs.python.org\/library\/xml.etree.elementtree.html\">Python and ElementTree<\/a> to edit the file with a structure like this<\/p>\n<p><!-- codeblock lang=\"\" line=\"1\" --><\/p>\n<pre><code>&lt;jaas&gt;\r\n\t&lt;JAASAuthData \r\n\t\talias=\"dmgr\/databaseuser\" \r\n\t\tdescription=\"The database user\" \r\n\t\tpassword=\"thepassword\" \r\n\t\tuserId=\"dbid\"&gt;\r\n\t&lt;\/JAASAuthData&gt;\r\n&lt;\/jaas&gt;\r\n<\/code><\/pre>\n<p><!-- \/codeblock --><\/p>\n<p>Used plenty of sources to help me out, but I do think I did use http:\/\/effbot.org\/ the most &#8211; super when it comes to figuring out Python, but http:\/\/www.rexx.com\/~dkuhlman\/pyxmlfaq.html was also of great help! <\/p>\n<p>The script I created is available here <a href=\"http:\/\/hellem.org\/filer\/updateJaas.py.txt\">updateJaas.py<\/a> The script is bound to changing jaas.xml-files, but it should be quite easy to change it for other needs as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Doing some work trying to update J2C resources defined in WebSphere using Rational Automation Framework, actually about the same thing as described in the article &#8220;A step-by-step guide to automating the deployment of a data source by using Rational Build Forge&#8221; and I needed to do some changes in jaas.xml. Won&#8217;t go into the details [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"class_list":["post-3625","post","type-post","status-publish","format-standard","hentry","category-work-geek"],"_links":{"self":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/3625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3625"}],"version-history":[{"count":1,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/3625\/revisions"}],"predecessor-version":[{"id":13981,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/3625\/revisions\/13981"}],"wp:attachment":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}