Note that there are some explanatory texts on larger screens.

plurals
  1. POFind and Replace Values in XML using Python
    primarykey
    data
    text
    <p>I am looking to edit XML files using python. I want to find and replace keywords in the tags. In the past, a co-worker had set up template XML files and used a "find and replace" program to replace these key words. I want to use python to find and replace these key words with values. I have been teaching myself the Elementtree module, but I am having trouble trying to do a find and replace. I have attached a snid-bit of my XML file. You will seen some variables surrounded by % (ie %SITEDESCR%) These are the words I want to replace and then save the XML to a new file. Any help or suggestions would be great.</p> <p>Thanks, Mike</p> <pre><code>&lt;metadata&gt; &lt;idinfo&gt; &lt;citation&gt; &lt;citeinfo&gt; &lt;origin&gt;My Company&lt;/origin&gt; &lt;pubdate&gt;05/04/2009&lt;/pubdate&gt; &lt;title&gt;POLYGONS&lt;/title&gt; &lt;geoform&gt;vector digital data&lt;/geoform&gt; &lt;onlink&gt;\\C$\ArcGISDevelopment\Geodatabase\PDA_STD_05_25_2009.gdb&lt;/onlink&gt; &lt;/citeinfo&gt; &lt;/citation&gt; &lt;descript&gt; &lt;abstract&gt;This dataset represents the mapped polygons developed from the field data for the %SITEDESCR%.&lt;/abstract&gt; &lt;purpose&gt;This dataset was created to accompany some stuff.&lt;/purpose&gt; &lt;/descript&gt; &lt;timeperd&gt; &lt;timeinfo&gt; &lt;rngdates&gt; &lt;begdate&gt;%begdate%&lt;/begdate&gt; &lt;begtime&gt;unknown&lt;/begtime&gt; &lt;enddate&gt;%enddate%&lt;/enddate&gt; &lt;endtime&gt;unknown&lt;/endtime&gt; &lt;/rngdates&gt; &lt;/timeinfo&gt; &lt;current&gt;ground condition&lt;/current&gt; &lt;/timeperd&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload