title: Get raw element representation including open and close tags
body: <p>I know about golang xml <code>,innerxml</code> tag which allows getting the element inner content as a raw xml. But what I need is to get the whole element (open tag, inner content, close tag) as a raw data. </p>
  
  <p>Here is a sample which I'd like to parse that way. I'd like to get the whole <code>&lt;Useful&gt;</code> with all its possible attributes element and avoid getting useless elements.</p>
  
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      "encoding/xml"
      "fmt"
  )
  
  const data = `&lt;Document&gt;
      &lt;Useless1&gt;
          blah-blah
      &lt;/Useless1&gt;
      &lt;Useless2&gt;
          blah-blah
      &lt;/Useless2&gt;
      &lt;Useful someAttr="someVal"&gt;
          &lt;InnerField1&gt;Inner field 1 value&lt;/InnerField1&gt;
          &lt;InnerField2&gt;Inner field 2 value&lt;/InnerField2&gt;
          &lt;InnerField3&gt;Inner field 3 value&lt;/InnerField3&gt;
      &lt;/Useful&gt;
      &lt;Useless3&gt;
          blah-blah
      &lt;/Useless3&gt;
  &lt;/Document&gt;
  `
  
  func main() {
      doc := Document{}
      err := xml.Unmarshal([]byte(data), &amp;doc)
      if err != nil {
          panic(err)
      }
  
      fmt.Println(doc.Useful.Data)
  }
  
  type Document struct {
      XMLName xml.Name `xml:"Document"`
      Useful  struct {
          Data string `xml:",innerxml"`
      } `xml:"Useful"`
  }
  </code></pre>
  
  <p>the link to the code in a playground is here:
  <a href="https://goplay.space/#0KDXiRKDwlY" rel="nofollow noreferrer">https://goplay.space/#0KDXiRKDwlY</a></p>
  
  <p>This is what I got:</p>
  
  <pre><code>    &lt;InnerField1&gt;Inner field 1 value&lt;/InnerField1&gt;
      &lt;InnerField2&gt;Inner field 2 value&lt;/InnerField2&gt;
      &lt;InnerField3&gt;Inner field 3 value&lt;/InnerField3&gt;
  </code></pre>
  
  <p>And this is what I'd like to get:</p>
  
  <pre><code>&lt;Useful someAttr="someVal"&gt;
      &lt;InnerField1&gt;Inner field 1 value&lt;/InnerField1&gt;
      &lt;InnerField2&gt;Inner field 2 value&lt;/InnerField2&gt;
      &lt;InnerField3&gt;Inner field 3 value&lt;/InnerField3&gt;
  &lt;/Useful&gt;
  </code></pre>
  
  <p>Please note that the actual structure I'm working with is much more complex. I wouldn't like to get the whole <code>&lt;Document&gt;</code> inner content as a raw xml and then parse it trying to get rid of useless elements manually. The <code>&lt;Useful&gt;</code> part varies, so I can't hardcode e.g. attributes cause they can differ from one document to another.</p>