title: Digging out of a self made XML hole
body: <p>I am using an XML datastore for a tool that, in part, addresses modifying INI files. To that end, I have some XML that looks like this...</p>
  
  <pre><code>&lt;ManageINI&gt;
     &lt;Target&gt;Target.ini&lt;/Target&gt;
     &lt;ReviseKey&gt;
        &lt;Section&gt;Section&lt;/Section&gt;
        &lt;Name&gt;Name&lt;/Name&gt;
        &lt;Value&gt;Value&lt;/Value&gt;
     &lt;/ReviseKey&gt;
  &lt;/ManageINI&gt;
  </code></pre>
  
  <p>Which of course is problematic because ReviseKey.Name is the name of that node, which conflicts with the child node. A better answer of course is to use <code>&lt;KeyName&gt;</code> and <code>&lt;KeyValue&gt;</code>.
  What I want to do now is look for 'Name' keys and flag them in a log as needing revision. However, I am so far unable to access them at all. I had thought that $node.'name' vs $node.name might get me there, but no.
  So, the question is, is there some way to force an XPath based approach to see these Name nodes so I can flag them, or have I dug myself a right deep hole that I can't really get out of in code?</p>
  
  <p>EDIT:
  So, would I use this to set a variable like so and then iterate nodes in that variable?</p>
  
  <pre><code>$invalid = $global:schemaXml.selectNodes("//ReviseKey[Name='Name']")
  </code></pre>
  
  <p>EDIT: It seems things are going to get even more messy down in my hole. I have many "Task" nodes, and I am doing my validation one by one on a node that has been passed as <code>[Xml.XmlElement]$task</code>. If I just test for something like $task.Name then I am going to get the name of the whole task, not the invalid Task.Name node. I also tried <code>$testnode = $task.selectSingleNode("/$($node.name)/$($childNode.invalid)")</code> where $childNode.invalid is "Name" in this case, and I am testing a child node condition, but here it seems like I am getting XPath based on the whole XML, not just the portion in the task node in question.
  So, is it possible to run XPath against just an XmlElement? Or is there a mechanism to use dot notation on the $task variable and limit it to nodes not attributes?</p>