title: Reading a specific XML node within several of the same type
body: <p>I am parsing a config tasks and I need to get all the tasks that don't have an "email on failure" part. Below is the section from the xml of the tasks.</p>
  
  <pre><code>&lt;Settings&gt;
      &lt;Tasks&gt;
          &lt;Task ID="916360623" Name="name1" Active="0" NextEID="21" CacheNames="random"&gt;
              &lt;Schedules/&gt;
              &lt;NextActions&gt;
                  &lt;NextAction DoIfSuccess="1" DoIfFailure="0" DoIfNoAction="0" DoAfter="Task" Type="Task" TaskID="545310265"/&gt;
                  &lt;NextAction DoIfSuccess="0" DoIfFailure="1" DoIfNoAction="0" DoAfter="Task" Type="Email" HostID="385322183" AddressTo="email1@email.com, email2@email.com" Subject="[TaskName] - [TaskStatus]" Message="emailMessageFail"/&gt;
                  &lt;NextAction DoIfSuccess="1" DoIfFailure="0" DoIfNoAction="0" DoAfter="Task" Type="Email" HostID="385322183" AddressTo="email1@email.com, email2@email.com" Subject="[TaskName] - [TaskStatus]" Message="emailMessageSuccess"/&gt;
              &lt;/NextActions&gt;
          &lt;/Task&gt;
          &lt;Task ID="701754236" Name="Task2" Active="0" NextEID="21" CacheNames="random"&gt;
              &lt;NextActions&gt;
                  &lt;NextAction DoIfSuccess="1" DoIfFailure="0" DoIfNoAction="0" DoAfter="Task" Type="Task" TaskID="840519929"/&gt;
                  &lt;NextAction DoIfSuccess="0" DoIfFailure="1" DoIfNoAction="0" DoAfter="Task" Type="Email" HostID="385322183" AddressTo="email1@email.com, email2@email.com" Subject="[TaskName] - [TaskStatus]" Message="emailMessage"/&gt;
              &lt;/NextActions&gt;
          &lt;/Task&gt;             
      &lt;/Tasks&gt;
  &lt;/Settings&gt;
  </code></pre>
  
  <p>I have a powershell script that cycles through each task, and each <code>&lt;NextAction&gt;</code> however, it doesn't seem to successfully only take the tasks I want. What would be the best way to get a report of the tasks that dont have a <code>DoIfFailue="1"</code> AND <code>Type="Email"</code>?</p>
  
  <pre><code>set-executionpolicy unrestricted
  [xml]$config = Get-Content c:\path\config.xml
  $allTasks = @()
  foreach($task in $config.Settings.Tasks.task){
      $taskID = $task.name
      foreach($nextAction in $task.NextActions.NextAction){
          if(($nextAction.DoIfFailure = "1") -AND ($nextAction.type = "Email")){
              $address = $nextAction.addressto
              $subject = $nextAction.subject
              $message = $nextAction.message
              $allTasks += @(New-Object -TypeName psobject -Property @{'ID' = $taskID; 'emailAddress' = $address; 'emailSubject' = $subject; 'emailMessage' = $message})
          }
      }
  }
  $allTasks | Export-Csv -Path c:\path\output.csv -notype
  </code></pre>