title: XML Xpath with variable to remove node
body: <p>Thanks to the help of @Mathias R. Jessen i was able to get this working but what I am trying to do is add a variable on the top of the script to set the model name but i am not having any luck. Any ideas?</p>
  <pre><code>$modelselect = &quot;HP EliteBook x360 830 G7&quot;
  
  $file = &quot;C:\Temp\test1.xml&quot;
  $xmlfile = [XML](Get-Content $file)
  $item = Select-Xml $xmlFile -XPath '//Model[./ModelName = &quot;$modelselect&quot;]'
  
  foreach($node in $item.Node)
  {
  $node.ParentNode.RemoveChild($node)
  }
  
  $xmlFile.Save($file)
  </code></pre>