I have XML from a couple of gigabytes. There are no spaces in XML.
So, I wrote a little C # code for splitting in single files (which has some additional code to do some things, like randomization during testing)
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; } } }
Then I parse the resulting files using PowerShell, mainly because itβs easier for me to work with the server, while the specifications can change, and I can change the script on the fly.
So ... what is the easiest way to convert the above to PowerShell and put [.Net here] first? should I read byte for byte only if it has "<cust" on one line and "omer>" on the next?
source share