Link to home
Start Free TrialLog in
Avatar of RyanAndres
RyanAndresFlag for United States of America

asked on

Read large XML file with Powershell

I have a 500mb+ xml file I need to break apart, but every time I do Get-Content file it is too large for memory. Is there any way to process each node in the root one at a time similar to reading a stream?

The error: Exception of type 'System.OutOfMemoryException' was thrown.
Avatar of rockiroads
rockiroads
Flag of United States of America image

Avatar of RyanAndres

ASKER

No, it uses $xml = [xml](gc file) ....

This is what I tried and it will load the entire file into memory.. which will cause the exception.
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cool I used XmlTextReader and Writer.