Implemented xml module
h3rald h3rald@h3rald.com
Sun, 30 Jul 2023 09:34:36 +0000
3 files changed,
23 insertions(+),
9 deletions(-)
M
min.nim
→
min.nim
@@ -28,6 +28,7 @@ minpkg/lib/min_sys,
minpkg/lib/min_io, minpkg/lib/min_dstore, minpkg/lib/min_fs, + minpkg/lib/min_xml, minpkg/lib/min_http, minpkg/lib/min_net, minpkg/lib/min_crypto,@@ -149,6 +150,7 @@ i.crypto_module
i.net_module i.math_module i.http_module + i.xml_module if customPrelude == "": i.eval PRELUDE, "<prelude>" else:
M
minpkg/lib/min_xml.nim
→
minpkg/lib/min_xml.nim
@@ -13,7 +13,7 @@ ../core/interpreter,
../core/utils -let xmltypes = "dict:xml-text|dict:xml-verbatim-text|xml-element|xml-cdata|xml-comment" +let xmltypes = "dict:xml-text|dict:xml-verbatim-text|dict:xml-element|dict:xml-cdata|dict:xml-comment|dict:xml-entity" proc newXDict(i: In, xml: XmlNode): MinValue = result = newDict(i.scope)@@ -123,5 +123,16 @@ let xdict = vals[0]
let query = vals[1].getString let root = i.newXml(xdict) i.push i.newXDict(root.querySelector(query)) + + def.symbol("xqueryall") do (i: In): + let vals = i.expect("dict:xml-element", "'sym") + let xdict = vals[0] + let query = vals[1].getString + let root = i.newXml(xdict) + let xresults = root.querySelectorAll(query) + var results = newSeq[MinValue](0) + for e in xresults: + results.add i.newXDict(e) + i.push results.newVal def.finalize("xml")
M
prelude.min
→
prelude.min
@@ -6,13 +6,14 @@ 'stack import
'seq import 'dict import 'time import -'io import -'fs import -'sys import -'dstore import -'crypto import -'math import -'net import -'http import +'io import +'fs import +'sys import +'dstore import +'crypto import +'math import +'net import +'http import +'xml import ; Unseal prompt symbol 'prompt unseal-symbol