Note that there are some explanatory texts on larger screens.

plurals
  1. POBash and Regular Expressions to remove tags in a xml file
    primarykey
    data
    text
    <p>I need to resolve a question that has kept me all day trying to resolve it.</p> <p>I have the following XML file:</p> <pre><code>&lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p class="subtit"&gt;Transporte:&lt;/p&gt; &lt;p&gt;Para transporte desde y hacia el Aeropuerto Internacional Arturo Merino Benítez (fono 56-2-690 19 00) existen diversas empresas que prestan este servicio: buses, minibuses y taxis. Se recomienda contratar transporte autorizado dentro del aeropuerto.&lt;/p&gt; &lt;TXT_accesp&gt; &lt;p&gt;Climate:&lt;/p&gt; &lt;p&gt;Santiago has a temperate Mediterranean climate with an annual average temperature of 14.5º Celsius. September is the start of spring, the climate is gentle and fresh with highs reaching 28 degrees during the day that drop to 6º C (43º F) to 12º C (54º F) at night.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Language:&lt;/p&gt; &lt;p&gt;Spanish&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;/TXT_accesp&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p class="subtit"&gt;Transporte:&lt;/p&gt; &lt;p&gt;Para transporte desde y hacia el Aeropuerto Internacional Arturo Merino Benítez (fono 56-2-690 19 00) existen diversas empresas que prestan este servicio: buses, minibuses y taxis. Se recomienda contratar transporte autorizado dentro del aeropuerto.&lt;/p&gt; </code></pre> <p>Then I remove all tags <code>&lt;p&gt; &lt;/ p&gt;</code> without deleting the text that is inside, but only those <code>&lt;p&gt; &lt;/ p&gt;</code> found <strong>inside the tag</strong> <code>&lt;TXT_accesp&gt; and &lt;/ TXT_accesp&gt;</code></p> <p>I'm doing it with bash as many files will be where I need to replace those tags. What I've done so far is the following:</p> <pre><code>sed -e 's/&lt;TXT_accesp&gt;&lt;p&gt;\(.*\)&lt;\/p&gt;&lt;\/TXT_accesp&gt;$/\1/g' example.xml </code></pre> <p>The idea is to remove all <code>&lt;p&gt; &lt;/ p&gt;</code> text or independent if they are not inside, but if you have text not removed. After that, the idea is that you save the changes.</p> <p><strong>Can you help me?</strong> </p> <p>Thirst is not whether the command is indicated or if I combine it with another. In addition, regular expressions do not know if it's correct.</p> <p>Thank you very much everyone!</p>
    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.
    1. This table or related slice is empty.
    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