Sed - Obtain all occurrence
<p>I'm trying to create script to edit a xhtml file. I want to replace the reference tag address for the referenced text. For example:</p>

<p>input:</p>

<pre><code>This is an example with &lt;a href="Ref1"&gt;three&lt;/a&gt; references.
The first reference is at the &lt;a href="Ref2"&gt;first line&lt;/a&gt; and the rest is at &lt;a href="Ref2"&gt;the second line&lt;/a&gt;.
</code></pre>

<p>output:</p>

<pre><code>This is an example with &lt;a href="three"&gt;three&lt;/a&gt; references.
The first reference is at the &lt;a href="first%20line"&gt;first line&lt;/a&gt; and the rest is at &lt;a href="the%20second%20line"&gt;the second line&lt;/a&gt;.
</code></pre>

<p>I had thought use SED command in two parts. First of all get the referenced text and next replace the address, but I'm stuck on the first SED command.</p>

<p>With the following command I have come to obtain the last referenced text by line:</p>

<pre><code>sed -n 's:.*"&gt;\(.*\)&lt;/a&gt;.*:\1:p' File.xml
</code></pre>

<p>How do I obtain all occurrence?</p>