title: Powershell HasChildNodes is true for text?
body: <p>When working with XML objects in Powershell should the HasChildNodes return true if the element just has text data and not another element? Is there not a way to identify elements that do not have any actual elements under them?</p>
  
  <p>Given the example below I was hoping that the element Parameter_Section would return true for having children, but I would not expect the elements inside to also return true if they had data. For example, SCM_Included, SendToApp, and WF_Start all return true because they have text. The definition says "Gets a value indicating whether this node has any child nodes". Does that mean text or data is considered a child node?</p>
  
  <p>I'm parsing a bunch of InfoPath XML files and I was hoping to be able to ignore the parent elements like Parameter_Section that only serve to organize (InfoPath calls them "sections") the child elements that actually store data (which are fields in InfoPath). </p>
  
  <pre><code>function ReadAllNodes ($node) {
  foreach ($childnode in $node.ChildNodes)
  {
      [string] $path = Get-XPath($childnode)
      [string] $nt = $childnode.NodeType
      [string] $hc = $childnode.HasChildNodes
      [string] $name = $childnode.Name
      [string] $val = $childnode.Value
      [string] $txt = $childnode.'#text'
  
      Write-Host (“Name={0}, path={1}, type={2}, hc={3}, val={4}, txt={5}” -f $name, $path, $nt, $hc,$val,$txt)
  }
  
  foreach ($cn in $childnode) {
      ReadAllNodes $cn
      }
  }
  
  $Xml = @"
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;myFields&gt;
      &lt;Parameter_Section&gt;
          &lt;Approval_Mode /&gt;
          &lt;SCM_Included&gt;n&lt;/SCM_Included&gt;
          &lt;ApprovalCompleteDateTime /&gt;
          &lt;ApprovalCompleteDateStr /&gt;
          &lt;SendToApp&gt;No&lt;/SendToApp&gt;
          &lt;WF_Start&gt;0&lt;/WF_Start&gt;
          &lt;QuoteAttachCount&gt;0&lt;/QuoteAttachCount&gt;
          &lt;TestEmail /&gt;
          &lt;TestMessage /&gt;
          &lt;IsCurrentUserRequestor&gt;true&lt;/IsCurrentUserRequestor&gt;
          &lt;CanCurrentUserApprove&gt;Approve&lt;/CanCurrentUserApprove&gt;
      &lt;/Parameter_Section&gt;
  &lt;/myFields&gt;
  "@
  
  $content = New-Object -TypeName XML
  $content.LoadXml($Xml)
  [System.Xml.XmlElement] $root = $content.get_DocumentElement()
  
  ReadAllNodes $root
  
  
  
  
  
      Name=Parameter_Section, path=/myFields/Parameter_Section, type=Element, hc=True, val=, txt=
  Name=Approval_Mode, path=/myFields/Parameter_Section/Approval_Mode, type=Element, hc=False, val=, txt=
  Name=SCM_Included, path=/myFields/Parameter_Section/SCM_Included, type=Element, hc=True, val=, txt=n
  Name=ApprovalCompleteDateTime, path=/myFields/Parameter_Section/ApprovalCompleteDateTime, type=Element, hc=False, val=, txt=
  Name=ApprovalCompleteDateStr, path=/myFields/Parameter_Section/ApprovalCompleteDateStr, type=Element, hc=False, val=, txt=
  Name=SendToApp, path=/myFields/Parameter_Section/SendToApp, type=Element, hc=True, val=, txt=No
  Name=WF_Start, path=/myFields/Parameter_Section/WF_Start, type=Element, hc=True, val=, txt=0
  Name=QuoteAttachCount, path=/myFields/Parameter_Section/QuoteAttachCount, type=Element, hc=True, val=, txt=0
  Name=TestEmail, path=/myFields/Parameter_Section/TestEmail, type=Element, hc=False, val=, txt=
  Name=TestMessage, path=/myFields/Parameter_Section/TestMessage, type=Element, hc=False, val=, txt=
  Name=IsCurrentUserRequestor, path=/myFields/Parameter_Section/IsCurrentUserRequestor, type=Element, hc=True, val=, txt=true
  Name=CanCurrentUserApprove, path=/myFields/Parameter_Section/CanCurrentUserApprove, type=Element, hc=True, val=, txt=Approve
  Name=#text, path=/myFields/Parameter_Section/CanCurrentUserApprove/#text, type=Text, hc=False, val=Approve, txt=
  </code></pre>