title: Cannot load an XML document with PowerShell
body: <p>Somehow I can't read an XML file with very simple structure in my PowerShell script. The XML file is generated by "Microsoft Log Parser Toolkit" and I want to load its contents into a database.</p>
  
  <p>The script is very simple:</p>
  
  <pre><code>$datalist=[xml] (gc ".\users.xml");
  foreach ($ROW in $datalist.ROOT.ROW) {
          Write-host $ROW.CompName;
  }
  </code></pre>
  
  <p>The expected output is </p>
  
  <pre><code>User1
  User2
  </code></pre>
  
  <p>but nothing gets printed out.  I have seen similar examples working (for instance <a href="http://pshell.info/basics/142/sharepoint-powershell-and-xml/" rel="nofollow noreferrer">here</a> where they use PowerShell to parse outputs of <code>stsadm -o enumsites</code>.</p>
  
  <p><strong>What am I missing here?</strong></p>
  
  <p>Contents of the users.xml is simple, too:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-10646-UCS-2" standalone="yes" ?&gt;
  &lt;!DOCTYPE ROOT[
   &lt;!ATTLIST ROOT DATE_CREATED CDATA #REQUIRED&gt;
   &lt;!ATTLIST ROOT CREATED_BY CDATA #REQUIRED&gt;
   &lt;!ELEMENT CompName (#PCDATA)&gt;
   &lt;!ELEMENT SoftwareName (#PCDATA)&gt;
   &lt;!ELEMENT ROW (CompName, SoftwareName)&gt;
   &lt;!ELEMENT ROOT (ROW*)&gt;
  ]&gt;
  &lt;ROOT DATE_CREATED="2009-12-30 10:44:23" CREATED_BY="Microsoft Log Parser V2.2"&gt;
   &lt;ROW&gt;
    &lt;CompName&gt;User1&lt;/CompName&gt;
    &lt;SoftwareName&gt;Adobe Reader 9.0&lt;/SoftwareName&gt;
   &lt;/ROW&gt;
   &lt;ROW&gt;
    &lt;CompName&gt;User2&lt;/CompName&gt;
    &lt;SoftwareName&gt;CorelDraw Graphics Suite X4&lt;/SoftwareName&gt;
   &lt;/ROW&gt;
  &lt;/ROOT&gt;
  </code></pre>