title: How to access the attribute of a parent node using F# Data's XML Type Provider?
body: <p>How to access the attribute of a parent node using <a href="http://fsharp.github.io/FSharp.Data/library/XmlProvider.html" rel="nofollow noreferrer">F# Data's XML Type Provider</a>? Let's say I have the following XML:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot;?&gt;
  &lt;ROOT&gt;
      &lt;level1 name=&quot;level1Name1&quot; x=&quot;8&quot;&gt;
          &lt;level2 name=&quot;level2Name1&quot; a=&quot;8&quot; b=&quot;104&quot; /&gt;
          &lt;level2 name=&quot;level2Name2&quot; a=&quot;85&quot; b=&quot;140&quot; /&gt;
      &lt;/level1&gt;
      &lt;level1 name=&quot;level1Name2&quot; x=&quot;10&quot;&gt;
          &lt;level2 name=&quot;level2Name3&quot; a=&quot;50&quot; b=&quot;500&quot; /&gt;
          &lt;level2 name=&quot;level2Name4&quot; a=&quot;376&quot; b=&quot;1065&quot; /&gt;
          &lt;level2 name=&quot;level2Name5&quot; a=&quot;10&quot; b=&quot;100&quot; /&gt;
          &lt;level2 name=&quot;level2Name6&quot; a=&quot;700&quot; b=&quot;700&quot; /&gt;
      &lt;/level1&gt;
      &lt;level1 name=&quot;level1Name3&quot; x=&quot;7&quot;&gt;
          &lt;level2 name=&quot;level2Name7&quot; a=&quot;502&quot; b=&quot;66&quot; /&gt;
      &lt;/level1&gt;
  &lt;/ROOT&gt;
  </code></pre>
  <p>And I want to use it in the below code:</p>
  <pre><code>open System
  open System.Xml.Linq
  open FSharp.Data
  
  type myXmlType = XmlProvider&lt;&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot;?&gt;&lt;ROOT&gt;&lt;level1 name=&quot;level1Name1&quot; x=&quot;8&quot;&gt;&lt;level2 name=&quot;level2Name1&quot; a=&quot;8&quot; b=&quot;104&quot; /&gt;&lt;level2 name=&quot;level2Name2&quot; a=&quot;85&quot; b=&quot;140&quot; /&gt;&lt;/level1&gt;&lt;level1 name=&quot;level1Name2&quot; x=&quot;10&quot;&gt;&lt;level2 name=&quot;level2Name3&quot; a=&quot;50&quot; b=&quot;500&quot; /&gt;&lt;level2 name=&quot;level2Name4&quot; a=&quot;376&quot; b=&quot;1065&quot; /&gt;&lt;level2 name=&quot;level2Name5&quot; a=&quot;10&quot; b=&quot;100&quot; /&gt;&lt;level2 name=&quot;level2Name6&quot; a=&quot;700&quot; b=&quot;700&quot; /&gt;&lt;/level1&gt;&lt;level1 name=&quot;level1Name3&quot; x=&quot;7&quot;&gt;&lt;level2 name=&quot;level2Name7&quot; a=&quot;502&quot; b=&quot;66&quot; /&gt;&lt;/level1&gt;&lt;/ROOT&gt;&quot;&quot;&quot;&gt;
  
  let myXml = myXmlType.Parse(&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot;?&gt;&lt;ROOT&gt;&lt;level1 name=&quot;level1Name1&quot; x=&quot;8&quot;&gt;&lt;level2 name=&quot;level2Name1&quot; a=&quot;8&quot; b=&quot;104&quot; /&gt;&lt;level2 name=&quot;level2Name2&quot; a=&quot;85&quot; b=&quot;140&quot; /&gt;&lt;/level1&gt;&lt;level1 name=&quot;level1Name2&quot; x=&quot;10&quot;&gt;&lt;level2 name=&quot;level2Name3&quot; a=&quot;50&quot; b=&quot;500&quot; /&gt;&lt;level2 name=&quot;level2Name4&quot; a=&quot;376&quot; b=&quot;1065&quot; /&gt;&lt;level2 name=&quot;level2Name5&quot; a=&quot;10&quot; b=&quot;100&quot; /&gt;&lt;level2 name=&quot;level2Name6&quot; a=&quot;700&quot; b=&quot;700&quot; /&gt;&lt;/level1&gt;&lt;level1 name=&quot;level1Name3&quot; x=&quot;7&quot;&gt;&lt;level2 name=&quot;level2Name7&quot; a=&quot;502&quot; b=&quot;66&quot; /&gt;&lt;/level1&gt;&lt;/ROOT&gt;&quot;&quot;&quot;)
  
  let howToDoIt =
      myXml.GetLevel1s()
      |&gt; Seq.collect (fun L1 -&gt; L1.GetLevel2s())
      |&gt; Seq.tryFind (fun L2 -&gt; L2.b = L1.x * L2.a) // *REMARK
      |&gt; function
      | None -&gt; &quot;&quot;
      | Some L2 -&gt; L2.Name
  </code></pre>
  <p>*<em>REMARK</em>: L1.x obviously won't work, but I want to achieve something similar.</p>