title: Using sed to extract element content of an XML file
body: <p>Well, using <code>sed</code> I'm trying to extract everything between <code>&lt;Transport_key&gt;</code> and <code>&lt;/Transport_key&gt;</code> from input files like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Envelope xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
  &lt;Header&gt;
  &lt;Security&gt;
  &lt;Transport_key&gt;
  &lt;EncryptedKey Id="TK" xmlns="http://www.w3.org/2001/04/xmlenc#"&gt;
  &lt;EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" /&gt;
  &lt;CipherData&gt;
  &lt;CipherValue&gt;pifKajuAK8FKwqLEhKIP4x5V5XUQyrwhpA&lt;/CipherValue&gt;
  &lt;/CipherData&gt;
  &lt;/EncryptedKey&gt;
  &lt;/Transport_key&gt;
  &lt;/Security&gt;
  &lt;/Header&gt;
  &lt;Body&gt;
  &lt;/Body&gt;
  &lt;/Envelope&gt;
  </code></pre>
  
  <p>so i want to get</p>
  
  <pre><code>&lt;EncryptedKey Id="TK" xmlns="http://www.w3.org/2001/04/xmlenc#"&gt;
  &lt;EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" /&gt;
  &lt;CipherData&gt;
  &lt;CipherValue&gt;pifKajuAK8FKwqLEhKIP4x5V5XUQyrwhpA&lt;/CipherValue&gt;
  &lt;/CipherData&gt;
  &lt;/EncryptedKey&gt;
  </code></pre>
  
  <p>regardless of any optional newlines between elements. I just want the text between the two strings unmodified, even if the input is a single big line.</p>
  
  <p>I tried with</p>
  
  <pre><code>sed -e "s@.*&lt;Transport_key&gt;\(.*\)&lt;/Transport_key&gt;.*@\1@" test.txt
  </code></pre>
  
  <p>but in the meantime I learned, that <code>sed</code> is taking inputs line per line and it cannot work.</p>
  
  <p>Is there a solution for that?</p>