XML : How can I modify the value of an Element Attribute within an xml using Python?

I have a bunch of unique xml files that contain non-unique identifier GUIDs. I am trying to replace these duplicate GUIDs so that every xml file has its own unique GUID.

Here is a snip-it of what the xml files look like:

  <?xml version="1.0" encoding="UTF-8"?>  <soa:ExportableProcedure xmlns:soa="urn:website.net:soa:core" hoursuntilexpiration="24" owner="00000000-0000-0000-0000-000000000000" simple="false" expires="true">      <soa:Procedure lockstate="unlocked" description="" name="File1" identifier="d2ccc4fa-a5ca-4cbd-bdec-9b5d2b42e52b">    

The "identifier" value is what I am trying to replace.

I have generated a bunch of GUIDs and stuck them in a text file. How can I use Python to call and then replace the identifier value?

No comments:

Post a Comment