title: Nested Array with objects return specific value
body: <p>I read an XML file:</p>
  <p>This is the layout:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;RadanCompoundDocument xmlns=&quot;http://www.radan.com/ns/rcd&quot;&gt;
    &lt;RadanAttributes&gt;
      &lt;Group class=&quot;system&quot; name=&quot;File&quot; desc=&quot;These attributes are basic properties of the file.&quot; ord=&quot;1&quot;&gt;
        &lt;Attr num=&quot;101&quot; name=&quot;Created&quot; desc=&quot;Time file was created.&quot; type=&quot;t&quot; ord=&quot;3&quot; value=&quot;2021-05-04T09:39:19+02:00&quot;&gt;
          &lt;Valid perm=&quot;r&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;102&quot; name=&quot;Modified&quot; desc=&quot;Time file was last modified.&quot; type=&quot;t&quot; ord=&quot;4&quot; value=&quot;2021-05-04T09:39:19+02:00&quot;&gt;
          &lt;Valid perm=&quot;r&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;103&quot; name=&quot;File size&quot; desc=&quot;File size in bytes.&quot; type=&quot;i&quot; ord=&quot;5&quot; value=&quot;17832&quot;&gt;
          &lt;Valid perm=&quot;r&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;105&quot; name=&quot;Associated files&quot; desc=&quot;Associated files.&quot; type=&quot;s&quot; ord=&quot;6&quot;&gt;
          &lt;Valid perm=&quot;h&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;107&quot; name=&quot;Extension&quot; desc=&quot;File name extension.&quot; type=&quot;s&quot; ord=&quot;2&quot; value=&quot;sym&quot;&gt;
          &lt;Valid perm=&quot;r&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;110&quot; name=&quot;File name&quot; desc=&quot;File name without its extension.&quot; type=&quot;s&quot; ord=&quot;1&quot; value=&quot;RingAlu3mm&quot;&gt;
          &lt;Valid perm=&quot;r&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;141&quot; name=&quot;Checkout user&quot; desc=&quot;The username to which this file is checked out&quot; type=&quot;s&quot; ord=&quot;7&quot;&gt;
          &lt;Valid perm=&quot;r&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;142&quot; name=&quot;Checkout time&quot; desc=&quot;The time at which this file was checked out&quot; type=&quot;t&quot; ord=&quot;8&quot;&gt;
          &lt;Valid perm=&quot;r&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;143&quot; name=&quot;Filestore&quot; desc=&quot;Radcontrol local filestore path&quot; type=&quot;s&quot; ord=&quot;9&quot;&gt;
          &lt;Valid perm=&quot;h&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;144&quot; name=&quot;Current version&quot; desc='A flag to show (when set to &quot;yes&quot;) that this is the current version of a file' type=&quot;s&quot; ord=&quot;10&quot;&gt;
          &lt;Valid perm=&quot;r&quot; /&gt;
        &lt;/Attr&gt;
      &lt;/Group&gt;
      &lt;Group class=&quot;custom&quot; name=&quot;Description&quot; desc=&quot;Use these attributes to give a description of the file.&quot; ord=&quot;2&quot;&gt;
        &lt;Attr num=&quot;108&quot; name=&quot;Title&quot; desc=&quot;The title of this file.&quot; type=&quot;s&quot; ord=&quot;1&quot;&gt;
          &lt;Valid perm=&quot;e&quot; max=&quot;80&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;109&quot; name=&quot;Comments&quot; desc=&quot;Comments about this file.&quot; type=&quot;s&quot; ord=&quot;2&quot;&gt;
          &lt;Valid perm=&quot;e&quot; /&gt;
        &lt;/Attr&gt;
      &lt;/Group&gt;
      &lt;Group class=&quot;custom&quot; name=&quot;Manufacturing&quot; desc=&quot;These attributes are the manufacturing properties of the file.&quot; ord=&quot;6&quot;&gt;
        &lt;Attr num=&quot;119&quot; name=&quot;Material&quot; desc=&quot;Material.&quot; type=&quot;s&quot; ord=&quot;1&quot; value=&quot;AlMg3 H111&quot;&gt;
          &lt;Valid perm=&quot;e&quot; max=&quot;20&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;120&quot; name=&quot;Thickness&quot; desc=&quot;Thickness.&quot; type=&quot;r&quot; ord=&quot;2&quot; value=&quot;3&quot;&gt;
          &lt;Valid perm=&quot;e&quot; min=&quot;0&quot; max=&quot;99999&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;121&quot; name=&quot;Thickness units&quot; desc=&quot;Thickness units.&quot; type=&quot;s&quot; ord=&quot;4&quot; value=&quot;mm&quot;&gt;
          &lt;Valid perm=&quot;e&quot; expr=&quot;mm|in|swg&quot; max=&quot;80&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;122&quot; name=&quot;Orientation&quot; desc=&quot;Allowed nest orientations (1=0°, 2=90°, 3=0/90°, 5=0/180°, 6=90/270°, 7=0/90/180/270°, 8=any).&quot; type=&quot;i&quot; ord=&quot;6&quot; value=&quot;1&quot;&gt;
          &lt;Valid perm=&quot;e&quot; min=&quot;1&quot; max=&quot;8&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;123&quot; name=&quot;Cycle time&quot; desc=&quot;Cycle time in minutes.&quot; type=&quot;r&quot; ord=&quot;24&quot;&gt;
          &lt;Valid perm=&quot;e&quot; min=&quot;0&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;127&quot; name=&quot;Machine&quot; desc=&quot;Machine name.&quot; type=&quot;s&quot; ord=&quot;18&quot;&gt;
          &lt;Valid perm=&quot;e&quot; max=&quot;80&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;132&quot; name=&quot;Mirror&quot; desc=&quot;Whether the part can be mirrored in nesting.&quot; type=&quot;s&quot; ord=&quot;7&quot;&gt;
          &lt;Valid perm=&quot;e&quot; expr=&quot;yes|no&quot; max=&quot;80&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;139&quot; name=&quot;STL id&quot; desc=&quot;Standard Tool Loading file id.&quot; type=&quot;i&quot; ord=&quot;19&quot; value=&quot;23&quot;&gt;
          &lt;Valid perm=&quot;e&quot; min=&quot;0&quot; max=&quot;99&quot; /&gt;
          &lt;MC machine=&quot;psys_LES_4&quot; value=&quot;23&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;145&quot; name=&quot;Common cutting&quot; desc=&quot;Whether the part is suitable for common line cutting in nesting.&quot; type=&quot;s&quot; ord=&quot;8&quot;&gt;
          &lt;Valid perm=&quot;e&quot; expr=&quot;none|unrestricted|same part&quot; max=&quot;80&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;146&quot; name=&quot;Strategy&quot; desc=&quot;Autotooling strategy.&quot; type=&quot;s&quot; ord=&quot;20&quot; value=&quot;Nitrogen&quot;&gt;
          &lt;Valid perm=&quot;e&quot; max=&quot;60&quot; /&gt;
          &lt;MC machine=&quot;psys_LES_4&quot; value=&quot;Nitrogen&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;160&quot; name=&quot;Picking cluster&quot; desc=&quot;Whether to nest the part in clusters that are suitable for a part picker.&quot; type=&quot;s&quot; ord=&quot;9&quot;&gt;
          &lt;Valid perm=&quot;e&quot; expr=&quot;yes|no&quot; max=&quot;80&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;164&quot; name=&quot;Weight&quot; desc=&quot;The weight of the part in lb or kg, depending on the geometry units attribute value.&quot; type=&quot;r&quot; ord=&quot;5&quot; value=&quot;0.01923785677&quot;&gt;
          &lt;Valid perm=&quot;e&quot; min=&quot;0&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;181&quot; name=&quot;Maximum CC group&quot; desc=&quot;The maximum number of parts in a common cut group.&quot; type=&quot;i&quot; ord=&quot;10&quot;&gt;
          &lt;Valid perm=&quot;e&quot; min=&quot;2&quot; max=&quot;999999&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;186&quot; name=&quot;Workflow status&quot; desc=&quot;The workflow status of this file.&quot; type=&quot;s&quot; ord=&quot;27&quot; value=&quot;1 - OK&quot;&gt;
          &lt;Valid perm=&quot;e&quot; max=&quot;80&quot; /&gt;
          &lt;MC machine=&quot;psys_LES_4&quot; value=&quot;1 - OK&quot; /&gt;
        &lt;/Attr&gt;
        &lt;Attr num=&quot;196&quot; name=&quot;Kit of parts&quot; desc=&quot;Symbol is a kit of parts.&quot; type=&quot;s&quot; ord=&quot;11&quot;&gt;
          &lt;Valid perm=&quot;e&quot; expr=&quot;yes|no&quot; max=&quot;80&quot; /&gt;
        &lt;/Attr&gt;
      &lt;/Group&gt;
      &lt;/Group&gt;
    &lt;/RadanAttributes&gt;
  &lt;/RadanCompoundDocument&gt;
  </code></pre>
  <p>I want to get the value of the object with name=&quot;Strategy&quot;
  so I do this:</p>
  <pre><code>const xml = fs.readFileSync(path)
  const result = {}
  let symXML = ''
  parser.parseString(xml, function(err, res) {
      if (err) {
          console.error('xml2js.parseString: Error occurred: ', err)
      } else {
          symXML = res
      }
  })
  const manufacturing = symXML.RadanCompoundDocument.RadanAttributes.Group.find(
      (el) =&gt; el.$.name === 'Manufacturing'
  )
  </code></pre>
  <p>what gives me the manufacturing section as an object</p>
  <pre><code>{
    '$': {
      class: 'custom',
      name: 'Manufacturing',
      desc: 'These attributes are the manufacturing properties of the file.',
      ord: '6'
    },
    Attr: [
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object], MC: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object], MC: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object] },
      { '$': [Object], Valid: [Object], MC: [Object] },
      { '$': [Object], Valid: [Object] }
    ]
  }
  </code></pre>
  <p>inside the array Attr it looks like this:</p>
  <pre><code>{
    '$': {
      num: '165',
      name: 'Bounding box X',
      desc: &quot;The maximum extent of the symbol's geometry in the X direction.&quot;,
      type: 'r',
      ord: '2',
      value: '75'
    },
    Valid: { '$': { perm: 'e', min: '0' } }
  }
  </code></pre>
  <p>and its here that i need the value of property 'value'</p>
  <p>This won't work:</p>
  <pre><code>const result = {}
  result.Strategy = manufacturing.Attr.find((el) =&gt; el.$.name === 'Strategy').$.value
  </code></pre>
  <p>Why does Array.prototype.find().$.value not give me a result?</p>
  <p>This works:</p>
  <pre><code>result.Strategy = manufacturing.Attr.find((el) =&gt; el.$.name === 'Strategy').$.value
  result.Strategy = result.Strategy.$.value
  </code></pre>
  <p>But that's just not right.</p>
  <p>Can someone please help me?</p>