Created
June 13, 2015 03:09
-
-
Save taotetek/aec7a9dffdd8b2480242 to your computer and use it in GitHub Desktop.
scratch parser test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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