title: Parsing XML to CSV using xq and jq
body: <p>There is some terminal command for parsing xml to csv in python xq syntax (also python-yq installed required):</p>
  <pre><code>xq -r '[.yml_catalog.shop.offers.offer[] | [.&quot;@id&quot;, .&quot;@available&quot;, .price, .name, .description]] | . |= [[&quot;id&quot;, &quot;available&quot;, &quot;price&quot;, &quot;name&quot;, &quot;description&quot;]] + . | .[] | @csv' source.yml &gt; result.csv
  </code></pre>
  <p>Here is xml file example:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
    &lt;yml_catalog date=&quot;2020-07-29 09:39&quot;&gt;
      &lt;shop&gt;
        &lt;offers&gt;
          &lt;offer id=&quot;17489&quot; available=&quot;true&quot;&gt;
            &lt;price&gt;1500&lt;/price&gt;
            &lt;name&gt;Item 1&lt;/name&gt;
            &lt;description&gt;Item 1 description&lt;/description&gt;
            &lt;param name=&quot;category type&quot;&gt;sale&lt;/param&gt;
            &lt;param name=&quot;size&quot;&gt;big&lt;/param&gt;
          &lt;/offer&gt;
          &lt;offer id=&quot;17490&quot; available=&quot;false&quot;&gt;
            &lt;price&gt;1100&lt;/price&gt;
            &lt;name&gt;Item 2&lt;/name&gt;
            &lt;description&gt;Item 2 description&lt;/description&gt;
            &lt;param name=&quot;category type&quot;&gt;main&lt;/param&gt;
            &lt;param name=&quot;size&quot;&gt;small&lt;/param&gt;
          &lt;/offer&gt;
          ...
        &lt;/offers&gt;
      &lt;/shop&gt;
    &lt;/yml_catalog&gt;
  </code></pre>
  <p>I need to add param tags for parsing. I've tried to handle its by <em>.&quot;param[@name=&quot;category type&quot;]&quot;</em>, <em>.&quot;param[@name=category type]</em> (the same for the param tag with size attribute), but it doesn't work.</p>
  <p>Necessary output csv:</p>
  <pre><code>&quot;id&quot;,&quot;available&quot;,&quot;price&quot;,&quot;name&quot;,&quot;description&quot;,&quot;category&quot;,&quot;size&quot;
  &quot;17489&quot;,&quot;true&quot;,&quot;1500&quot;,&quot;Item 1&quot;,&quot;Item 1 description&quot;,&quot;sale&quot;,&quot;big&quot;
  &quot;17490&quot;,&quot;false&quot;,&quot;1100&quot;,&quot;Item 2&quot;,&quot;Item 2 description&quot;,&quot;main&quot;,&quot;small&quot;
  </code></pre>
  <p>Please give me advice how to handle tags with exact properties with values and get its text text contents?</p>
  <p>Thank you!</p>