I have an XML of couple of gigabytes. There are no spaces in the XML.
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)
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;
}
}
}
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.
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 "" on the next?
No comments:
Post a Comment