Assumes input xml is valid, which allows constant memory usage (<4 MB) and faster parsing. For a fully-featured, but memory-bound converter see the xml-to-json package.
If not input file is given, reads from stdin (so it can be used in a unix pipe chain).