John,
The XML module is not necessarily "new", just "fixed" (somewhat).
It still requires libxml.dll, iconv.dll, and zlib1.dll files, which add up to about 2megs worth of external dependencies.
I've finished the preliminary work on a replacement xml module, called "mxml". It requires NO external dependencies.
Using the following xml file as a test:
<?xml version="1.0" encoding="UTF-8" ?>
<stufflist>
<stuff_test>This is a test!</stuff_test>
<stuff_test2>And this is another test!</stuff_test2>
<stuff_test3>
<painting>
<img src="madonna.jpg" alt='Foligno Madonna, by Raphael'/>
<caption>This is Raphael's "Foligno" Madonna, painted in
<date>1511</date>.
</caption>
</painting>
</stuff_test3>
<books>
<book>
<id>1</id>
<name>Hello, world!</name>
</book>
<book>
<id>2</id>
<name>Hello, China!</name>
</book>
</books>
</stufflist>
I can parse it like so:
include "c:\scriptbasic\include\mxml.bas"
filename = "stuff.xml"
doc = mxml::LoadDoc(filename)
node = mxml::GetNode(doc,"/stufflist/stuff_test")
if node then print "Test1: ", mxml::GetNodeValue(node),"\n"
node = mxml::GetNode(doc,"/stufflist/stuff_test2")
if (node) then print "Test2: ", mxml::GetNodeValue(node),"\n\n"
node = mxml::GetNode(doc,"/stufflist/stuff_test3/painting/img")
if node then
print "Image: ", mxml::GetProperty(node,"src"), "\n"
print "Alt Image: ", mxml::GetProperty(node,"alt"), "\n\n"
endif
node = mxml::GetNode(doc,"/stufflist/books")
child = mxml::GetChild(node)
while child
node = mxml::GetNode(child,"id")
if node then print "ID = ", mxml::GetNodeValue(node),"\n"
node = mxml::GetNode(child,"name")
if node then print "Name = ", mxml::GetNodeValue(node),"\n"
child = mxml::GetNext(child)
wend
if doc then mxml::FreeDoc(doc)
I coded this to use an XPATH-like call to get a pointer/handle to a given node.
Here's the output:
C:\Scriptbasic\mxmltest>\Scriptbasic\bin\scriba.exe mxmltest.sb
Test1: This is a test!
Test2: And this is another test!
Image: madonna.jpg
Alt Image: Foligno Madonna, by Raphael
ID = 1
Name = Hello, world!
ID = 2
Name = Hello, China!
I'll send you the mxml module in a bit so you can test before adding to the RC.
A.