Browse Source

Added XML module based on mxml

Armando Rivera 1 year ago
parent
commit
f1ef1db5a0
1 changed files with 37 additions and 0 deletions
  1. 37 0
      Modules/xml/xml.inc

+ 37 - 0
Modules/xml/xml.inc

@@ -0,0 +1,37 @@
+$LDFLAGS "-lmxml"
+
+$header
+    #include <mxml.h>
+$header
+
+$typedef mxml_node_t* NODE
+
+Sub xmlDelete(root as NODE)
+    mxmlDelete(root)
+End Sub
+
+Function xmlLoad(fname$) as NODE
+    raw tmpnode as NODE
+    open fname$ for input as fp
+    tmpnode = mxmlLoadFile(NULL, fp, MXML_OPAQUE_CALLBACK)
+    close fp
+    Function = tmpnode
+End Function
+
+Function xmlFind(root as NODE,element$) as NODE
+    raw tmpnode as NODE
+    tmpnode = mxmlFindElement(root, root, element$, NULL, NULL, MXML_DESCEND)
+    Function = tmpnode
+End Function
+
+Function xmlNext(node as NODE,root as NODE,element$) as NODE
+    raw tmpnode as NODE
+    tmpnode = mxmlFindElement(node, root, element$, NULL, NULL, MXML_DESCEND)
+    Function = tmpnode
+End Function
+
+Function xmlGet$(node as NODE, element$)
+    dim tmpStr$
+    tmpStr$ = mxmlGetOpaque$(mxmlFindPath(node, "*" & element$))
+    Function = tmpStr$
+End Function