Skip to content

Instantly share code, notes, and snippets.

@taotetek
Created June 13, 2015 03:09
Show Gist options
  • Save taotetek/aec7a9dffdd8b2480242 to your computer and use it in GitHub Desktop.
Save taotetek/aec7a9dffdd8b2480242 to your computer and use it in GitHub Desktop.
scratch parser test
import os, streams, parsexml, strutils
if paramCount() < 1:
quit("Usage: parse filename[.xml]")
var filename = addfileExt(paramStr(1), "xml")
var s = newFileStream(filename, fmRead)
if s == nil: quit("Cannot open the file" & filename)
var x: XmlParser
open(x, s, filename)
next(x)
block mainLoop:
while true:
case x.kind
of xmlEof: break
of xmlElementOpen, xmlElementStart:
echo "name: ", x.elementName
else: discard
next(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment