title: jsoup remove outer html tag - code HTML element
body: <p>This seems pretty straightforward but, obviously I'm doing something wrong.  Here is my HTML - I am trying to create both singular code tags and nested code tags under pre tags - the resulting content will be "one line boxes with code inside" and also with the pre tags "big boxes with code inside".  There are also empty paragraph tags that I can't get rid of using the standard methods - element remove after testing for no Text in the paragraph.  Here's the input</p>
  
  <pre><code>        &lt;h1&gt;Module Description and Learning Objectives&lt;/h1&gt;  
          &lt;p&gt; 
          &lt;/p&gt; 
          &lt;pre&gt;                
          &lt;p&gt;
          &lt;code&gt;2020-02-13 12:49:15 DEBUG StackTraceElement:48 -&lt;/code&gt;
          &lt;/p&gt;
          &lt;p&gt;
          &lt;code&gt;2020-02-13 12:49:15 DEBUG StackTraceElement:48 - sects.title&lt;/code&gt;
          &lt;/p&gt;
          &lt;p&gt;
          &lt;code&gt;2020-02-13 12:49:15 DEBUG StackTraceElement:48 - sects.id=1&lt;/code&gt;
          &lt;/p&gt;
          &lt;p&gt;
          &lt;/p&gt;
          &lt;/pre&gt; 
          &lt;p&gt;Sentence 1&lt;/p&gt; 
          &lt;p&gt; 
          &lt;code&gt;System.out.println("id:"+element.attr("id"));&lt;/code&gt; 
          &lt;/p&gt; 
          &lt;p&gt;Sentence 2&lt;/p&gt; 
          &lt;p&gt; 
          &lt;code&gt;System.out.println("src:"+element.attr("src"));&lt;/code&gt; 
          &lt;/p&gt; 
          &lt;p&gt;Sentence 3&lt;/p&gt; 
          &lt;p&gt; 
          &lt;code&gt;System.out.println("alt:"+element.attr("alt"));&lt;/code&gt; 
          &lt;/p&gt; 
          &lt;p&gt; 
          &lt;/p&gt; 
  </code></pre>
  
  <p>This is my code (don't follow names as much as constructs, mid-code names   :)</p>
  
  <pre><code>          Elements pWithCodeTagList = docXMLformat.select("code");
            if (pWithCodeTagList.size() &gt; 0) {
                for (Element pTag : pWithCodeTagList) {
                     System.out.println("pTag=" + pTag.text() + " " + pTag.tagName());
                     pTag.unwrap();
                }
            }
  </code></pre>
  
  <p>Here is the output in eclipse - I am indeed selecting the code tags and expecting the parent p to disappear</p>
  
  <pre><code> pTag=2020-02-13 12:49:15 DEBUG StackTraceElement:48 - code
   pTag=2020-02-13 12:49:15 DEBUG StackTraceElement:48 - sects.title code
   pTag=2020-02-13 12:49:15 DEBUG StackTraceElement:48 - sects.id=1 code
   pTag=System.out.println("id:"+element.attr("id")); code
   pTag=System.out.println("src:"+element.attr("src")); code
   pTag=System.out.println("alt:"+element.attr("alt")); code
  </code></pre>
  
  <p>This is the result:  I expected the paragraph tags to disappear, not the code tags!</p>
  
  <pre><code>   &lt;h1&gt;Module Description and Learning Objectives&lt;/h1&gt; 
                  &lt;p&gt; 
                  &lt;/p&gt; 
                  &lt;pre&gt;                
                      &lt;p&gt;
                      2020-02-13 12:49:15 DEBUG StackTraceElement:48 -
                  &lt;/p&gt;
                      &lt;p&gt;
                      2020-02-13 12:49:15 DEBUG StackTraceElement:48 - sects.title
                  &lt;/p&gt;
                      &lt;p&gt;
                      2020-02-13 12:49:15 DEBUG StackTraceElement:48 - sects.id=1
                  &lt;/p&gt;
                      &lt;p&gt;
                      &lt;/p&gt;
                  &lt;/pre&gt; 
                  &lt;p&gt;Sentence 1&lt;/p&gt; 
                  &lt;p&gt; System.out.println("id:"+element.attr("id")); &lt;/p&gt; 
                  &lt;p&gt;Sentence 2&lt;/p&gt; 
                  &lt;p&gt; System.out.println("src:"+element.attr("src")); &lt;/p&gt; 
                  &lt;p&gt;Sentence 3&lt;/p&gt; 
                  &lt;p&gt; System.out.println("alt:"+element.attr("alt")); &lt;/p&gt; 
                  &lt;p&gt; 
                  &lt;/p&gt; 
  </code></pre>
  
  <p>I already touch this area of my document, I've removed a span tag around the code tag prior to this, and had to remove all the line control characters from the line content, maybe PRE and CODE don't work like other tags - I know they are not supposed to, but ...   also, I'm trying to keep the tags and content on the same line so my "code boxes" are as slim as possible, towit:</p>
  
  <pre><code> &lt;pre&gt;                
   &lt;code&gt;2020-02-13 12:49:15 DEBUG StackTraceElement:48 -&lt;/code&gt;
   &lt;code&gt;2020-02-13 12:49:15 DEBUG StackTraceElement:48 - sects.title&lt;/code&gt;
   &lt;code&gt;2020-02-13 12:49:15 DEBUG StackTraceElement:48 - sects.id=1&lt;/code&gt;
    &lt;/pre&gt; 
    &lt;p&gt;Sentence 1&lt;/p&gt; 
    &lt;code&gt;System.out.println("id:"+element.attr("id"));&lt;/code&gt; 
    &lt;p&gt;Sentence 2&lt;/p&gt; 
    &lt;code&gt;System.out.println("src:"+element.attr("src"));&lt;/code&gt; 
    &lt;p&gt;Sentence 3&lt;/p&gt; 
    &lt;code&gt;System.out.println("alt:"+element.attr("alt"));&lt;/code&gt; 
  </code></pre>