MaXML - An XML module for BlitzMax

Community Forums/Showcase/MaXML - An XML module for BlitzMax

John J.(Posted 2005) [#1]
MaXML makes it easy to load, manipulate, and save XML files. MaXML is a very easy to use library of functions for manipulating xml data, including a fast xml parser (which parses roughly twice as fast as Microsoft Internet Explorer's XML viewer) and saver, including encryption support to protect your saved games, high scores, etc. from being edited by players. XML is a widely used and accepted format applied anywhere from word-processors to level builders.

Ported to BlitzMax by Bryan Laroche (TeaVirus).

Click here for a BlitzBasic version of MaXML

Included with MaXML.zip is a function reference manual, and example code.

To install, simply drag the "maxml.mod" folder in the MaXML archive to your the mod/pub.mod folder under your BlitzMax install.

License: MaXML is completely free for commercial and personal use.

Download MaXML 1.9 Module (ZIP) - 48 KB

1.9 - Added file encryption (optional), and several other features, including xmlNode.ChildIndex(), xmlNode.GetNextSibling(), and xmlnode.GetPrevSibling().
1.81 - Version 1.81 fixes the incompatibility with BlitzMax 1.14
1.8 - Version 1.8 includes a major bug fix where the example.xml file would cause errors.
1.7 - Version 1.7 includes some misc. bug fixes.
1.6 - Now MaxML can load XML files with the standard "<?xml ... ?>" header tag. BlitzXML also saves it's XML files with a header for compatibility with other applications.
1.5 - Code ported from blitzbasic (BlitzXML) to blitzmax by Bryan Laroche (TeaVirus).


WendellM(Posted 2005) [#2]
Thanks, but there seems to be a problem or two.

I downloaded the Zip, placed maxml.mod folder in mod/pub.mod and tried running example.bmx. I get the unhandled exception: "Attempt to index array element beyond array length" on line 17, which is doc1.Load("example.xml"). Max is using the mod, otherwise it'd report a problem with line 8's Local miscinfo:xmlNode.

Also, I can't open the included example.xml in Mozilla or IE without an error. They both complain about the next-to-last line: <miscinfo count="4"/>.


Muttley(Posted 2005) [#3]
Getting the same "Attempt to index array element beyond array length" error here.

Muttley


deps(Posted 2005) [#4]
Got the error too. And firefox didn't like example.xml at all.
MaXML looks cool so I hope you fix the bug soon.


Jay Kyburz(Posted 2005) [#5]
did these problems get sorted out? I'd love to use this mod.


John J.(Posted 2005) [#6]
Not yet. I'll upload a new version as soon as it's fixed.


Jeroen(Posted 2005) [#7]
good idea John.J! A welcome addition to Blitzmax


Jay Kyburz(Posted 2005) [#8]
You rock John!


John J.(Posted 2005) [#9]
Update: The bug has finially been fixed. Download the new version with the link above (now version 1.8)


bradford6(Posted 2005) [#10]
1.8 does not seem to work.

I dropped it into mod folder and ran example. get error:
'Find the node that containd the information we want.
infonode = doc1.FindNode("info")


unhandled exception


John J.(Posted 2005) [#11]
I just updated to the latest BlitzMax version and got the error too. Apparently it worked with the old version of BlitzMax I had but doesn't work now for some reason. I'll see if I can track down the problem as soon as possible.


John J.(Posted 2005) [#12]
Update: BlitzMax 1.14 incompatibility fixed.
It seems all I needed to do was rebuild the module with the new version, and it worked fine :)


bradford6(Posted 2005) [#13]
spot on. works fine now. nice work John J. this is a very useful addition to BMAX


Brendane(Posted 2005) [#14]
Hi, this is great, thanks.

I do have a couple of suggestions. I have also written a simple XML document parser in C++, and it's very similar to yours but I also have extended functions for getting / setting attributes /contents as different data types - makes life simpler when coming to use the library.

ie. node.GetIntData() / node.SetIntData()
node.GetFloatData() / nodeSetFloatData()
node.GetTextData() / node.SetTextData()

Also, the biggest difference is that I translate xml escape codes for markup characters... so,

SetData() would convert the following characters
< becomes &lt;
> becomes &gt;
" becomes &quot;
' becomes &apos;
& becomes &amp;

also, non printables become
&#nn; (where nn is the ascii code)

GetData() then retranslates those &xxxx; type codes back into the actual characters.


John J.(Posted 2005) [#15]
Brendane: Thanks for the suggestions. I'm currently adding the features you mentioned (and a few more) to MaXML and BlitzXML.
&#nn; (where nn is the ascii code)

Is "nn" supposed to be hexadecimal?


John J.(Posted 2006) [#16]
MaXML Version 1.9 Released!


New features include:

+ Light encryption support, which guards against players from changing high-score data, etc.

+ New optional function variants of GetData, SetData, GetAttributeValue, and SetAttributeValue for specific data types (for example, GetDataI() gets integer data, GetDataF() gets float data, and GetDataS() gets string data).

+ xmlNode.GetChildIndex() added.

+ xmlNode.GetFirstChild() added, which can be used along with xmlNode.GetNextSibling() and xmlNode.GetPrevSibling() as an alternate way to cycle through node children.

+ xmlNode.GetNextSibling() added, which can be used as an alternate way of cycling through node children.

+ xmlNode.GetPrevSibling() added, which can be used as an alternate way of cycling through node children.


The new features will be added to BlitzXML soon.


Leon Drake(Posted 2008) [#17]
hey i cant load from a tbank anymore??


Leon Drake(Posted 2008) [#18]
NVM somehow i grabbed the wrong version.