title: Shell scripting - split xml into multiple files
body: <p>Am trying to split a big xml file into multiple files, and have used the following code in AWK script.</p>
  
  <pre><code>/&lt;fileItem&gt;/ {
          rfile="fileItem" count ".xml"
          print "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;" &gt; rfile
          print $0 &gt; rfile
          getline
          while ($0 !~ "&lt;\/fileItem&gt;" ) {
                  print &gt; rfile
                  getline
          }
          print $0 &gt; rfile
          close(rfile)
          count++
  }
  </code></pre>
  
  <p>The code above generates a list of xml files whose names read "fileItem_1", "fileItem_2", "fileItem3", etc.</p>
  
  <p>However, I would like the file name to be something like "item_XXXXX" where the XXXXX is a node inside the XML - depicted as below</p>
  
  <pre><code>&lt;fileItem&gt;
  &lt;id&gt;12345&lt;/id&gt;
  &lt;name&gt;XXXXX&lt;/name&gt;
  &lt;/fileItem&gt;
  </code></pre>
  
  <p>So, basically I want the "id" node to be the filename.
  Can anyone please help me with this?</p>