title: How can i use XmlReader in PowerShell to stream big/huge XML files?
body: <p>I have an XML of couple of gigabytes. There are no spaces in the XML.</p>
  
  <p>So I wrote a little C# code to split in single files (which has some additional code to perform some stuff e.g. randomizing while testing)</p>
  
  <pre><code>using (XmlReader MyReader = XmlReader.Create(@"d:\xml\test.xml"))
              {
                  while (MyReader.Read())
                  {
                      switch (MyReader.NodeType)
                      {
                          case XmlNodeType.Element:
                              if (MyReader.Name == "Customer")
                              {
                                  XElement el = XElement.ReadFrom(MyReader) as XElement;
                                  if (el != null)
                                  {
                                      custNumber = (string)el.Element("CustNumber");
                                      output = @"d:\xml\output\" + custNumber;
  
                                      File.WriteAllText(output, el.ToString());
                                  }                                    
                              }
                              break;
                      }
                  }
              }
  </code></pre>
  
  <p>I then parse the resulting files with PowerShell, basically because I find it easier to work with on the server while specs can change and I can on the fly change the script.</p>
  
  <p>So... what is the easiest way to convert the above to PowerShell also, putting [.Net here] before everything ? would I have to read byte for byte just in the case it has <code>"&lt;cust"</code> on one line and <code>"omer&gt;"</code> on the next?</p>