title: LuaXML parse the XML with multiple tags with the same name
body: <p>I'm trying to parse data from XML files like</p>
  
  
  
  <pre><code>&lt;level&gt;
    &lt;bg&gt;details1&lt;/bg&gt;
    &lt;bg&gt;details2&lt;/bg&gt;
  &lt;/level&gt;
  </code></pre>
  
  <p>With  <a href="http://viremo.eludi.net/LuaXML/" rel="nofollow">xml.find(bg)</a> I can only get details 1 out. It's because  xml.find Returns the first (sub-)table which matches the search condition or nil.</p>
  
  <p>If I want to read both bg out. How could I achieve it in LuaXML? Or please introduce other Lua XML library works.</p>
  
  <p>Addons
  My real scenario is like this</p>
  
  <pre><code>&lt;a&gt;
     &lt;b&gt;
      &lt;level&gt;
        &lt;bg&gt;details1&lt;/bg&gt;
      &lt;/level&gt;
      &lt;level&gt;
        &lt;bg&gt;details2&lt;/bg&gt;
      &lt;/level&gt;
     &lt;/b&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>I know I need to get whole b object out and use xml.tag to read level out. But my attempts fail. Could you help me on this code?</p>
  
  <hr>
  
  <p>I finally get my solution like this based on Mike Corcoran's suggestion.</p>
  
  <pre><code>require 'luaxml'
  
  local text = [[
  &lt;a&gt;
     &lt;bcde&gt;
      &lt;level&gt;
        &lt;bg&gt;details1&lt;/bg&gt;
      &lt;/level&gt;
      &lt;level&gt;
        &lt;bg&gt;details2&lt;/bg&gt;
      &lt;/level&gt;
     &lt;/bcde&gt;
  &lt;/a&gt;
  ]]
  
  local txml = xml.eval(text)
  for _, node in pairs(txml:find("bcde")) do
   if node.TAG ~= nil then
          if node[node.TAG] == "level" then
              local bg = node:find("bg")
                  if bg ~= nil then
                  for i=1, #bg do
                      print( bg[i])
                  end
              end
          end
      end
  end
  </code></pre>
  
  <p>There are too many layers and seems slow.. Any suggestion to improve efficiency?</p>