title: Spark Python - Select from a struct and returning from a specific depth
body: <p>I'm new to Spark and Python - working in a Jupyter notebook.</p>
  
  <p>Say I have the following XML:</p>
  
  <pre><code>&lt;metadata&gt;
      &lt;person&gt;
          &lt;personalName&gt;
              &lt;surname&gt;The Batmaner&lt;/surname&gt;
          &lt;/personalName&gt;
          &lt;personalName&gt;
              &lt;surname&gt;Batman&lt;/surname&gt;
          &lt;/personalName&gt;
      &lt;/person&gt;
  &lt;/metadata&gt;
  </code></pre>
  
  <p>I've loaded this into a DateFrame using:</p>
  
  <p><code>df = spark.read.format("com.databricks.spark.xml").options(rowTag='metadata').load(path)</code></p>
  
  <p>Now I can see the data in <code>df</code> I want to pull out the whole section from <code>&lt;person&gt;</code> if <code>surname==Batman</code></p>
  
  <p>Essentially, I'm confused about 2 bits:</p>
  
  <ul>
  <li>Searching when there is that <code>struct</code> or repeating block so in my case multiple <code>personalName</code>s</li>
  <li>How to return everything from the <code>&lt;person&gt;</code> level</li>
  </ul>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks.</p>