Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / XML Plugin for DBPro

Author
Message
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 18th Feb 2011 14:29 Edited at: 22nd Jul 2011 01:51
Heres a new XML plugin for DBPro. It allows you to load, read, edit and save XML files. No external plugins needed.

You can use XML files to store map data in a structured way, heres an example XML file:



The data inside the XML file can be whatever you want it to be. You can use this plugin to import anything which can be put into XML format, including XHTML, SVG and whatever file format you want to create for your programs!

The plugin can also edit or create XML files which you can write data to and save out, without having to create your own XML exporter.


Download: (1.01 R1 10/3/2011)

DOWNLOAD

TORRENT:



Source code:

DOWNLOAD


The plugin uses TinyXML which is released under the Zlib licence, so there very few limitations on what your allowed to do with it.

The wrapper part of the plugin (Everything outside the TinyXML folder) is released into the Public Domain.

Your signature has been erased by a mod please reduce it to no larger than 600 x 120.

Attachments

Login to view attachments
Ermes
20
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 18th Feb 2011 14:33
i think it's great.

just sorry about i don't know nothing on what XML is.


Ciao facce da sedere!
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 18th Feb 2011 14:43 Edited at: 5th Jun 2011 13:54
XML is a format to store data inside files, the example in the first post shows you what XML looks like. You can use XML to make getting data out of files much easier, it also makes it easier for you to store data about maps, players, weapons, etc.

http://en.wikipedia.org/wiki/Xml

Your signature has been erased by a mod please reduce it to no larger than 600 x 120.

Attachments

Login to view attachments
Ermes
20
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 18th Feb 2011 15:08
! sudden and terrible headache !

i've readed what XML is, ok, but i've to ask if you are so kind to upload a little demo of this plugin, i know is a gift for all us, but if you aren't aware of XML utilization, it will be totally unusable. otherwise nevermind!!!


Ciao facce da sedere!
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 18th Feb 2011 19:30
@ Kaedroho,

Damn handy! Would I be right in thinking that this xml plugin can cope with more than one attribute per xml node?

Some more commands?

GETXMLCURRENTNODEID
GETXMLCURRENTNODENAME
GETXMLCURRENTNODEVALUE
SETXMLCURRENTNODENAME
SETXMLCURRENTNODEVALUE

XMLNODEIDEXIST

XMLINSERTNEXTNODE (create a node at current level and not a child node)

GETXMLNODECOUNT

GETXMLCHILDNODECOUNT

GETXMLSIBLINGNODECOUNT

GETXMLFIRSTNODEATTRIBUTE
GETXMLPREVIOUSNODEATTRIBUTE
GETXMLNEXTNODEATTRIBUTE
GETXMLLASTNODEATTRIBUTE

XMLCHANGENODEATTRIBUTENAME
XMLCHANGENODEATTRIBUTEVALUE

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 18th Feb 2011 21:54 Edited at: 18th Feb 2011 21:58
Yes, you can have more than 1 attribute per node. Some of those commands are already done.


Quote: "GETXMLCURRENTNODENAME
GETXMLCURRENTNODEVALUE
SETXMLCURRENTNODENAME
SETXMLCURRENTNODEVALUE"


Get node value gets the name, to get the text inside a node, you simply go to its first child and get the value of that. Text counts as a node.


Quote: "XMLINSERTNEXTNODE"

You can do this by going to the parent node and creating a new node.


Quote: "GETXMLFIRSTNODEATTRIBUTE
GETXMLPREVIOUSNODEATTRIBUTE
GETXMLNEXTNODEATTRIBUTE
GETXMLLASTNODEATTRIBUTE"


These are done but in a different way. You look at attributes by their name, GETXMLNODEATTRIBUTE seccond parameter is the name of the attribute you want to get.


Quote: "XMLCHANGENODEATTRIBUTENAME
XMLCHANGENODEATTRIBUTEVALUE"


Attribute name will need you do delete and recreate the attribute, Change the value is already added.


I will work on better documentation and some examples.

Your signature has been erased by a mod please reduce it to no larger than 600 x 120.
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 18th Feb 2011 23:12
@ Kaedroho - thanks for the further explanation.

Look forward to the help documentation / examples. I always find it hard to think in nodes, sub nodes...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 24th Feb 2011 16:00 Edited at: 24th Feb 2011 16:01
Sorry for the delay, I have been away recently.

Heres the source code to this plugin:

ZIP
RAR


I'll have an example up soon.

Your signature has been erased by a mod please reduce it to no larger than 600 x 120.
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 24th Feb 2011 23:41 Edited at: 24th Feb 2011 23:51
@ Kaedroho,

Thanks for that. What happens if you try to set to a previous or a next sibling or a child node when there isn't one? does the focus just stay with the current node or does it crash?

Also is it right that you need to create a child node of a current node and the child node needs to be an element node before you can add then attributes to that child element node??

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 25th Feb 2011 15:42
Quote: "What happens if you try to set to a previous or a next sibling or a child node when there isn't one?"


Those commands will return 0 and the current node doesn't change.

They will return 1 if they did find a child node. This allows you to do things like.

if KD GetXMLFirstChildNode(XML,"position")
position object blah blah blah
endif

So you only do something when the tag is there.


The child node must be an element in order to add attributes to it.

Your signature has been erased by a mod please reduce it to no larger than 600 x 120.
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 25th Feb 2011 15:45
Heres an example.

The example creates 2 objects, positions and colours them and positions, rotates and colours the backdrop of the camera.

Heres the code:


Heres the xml. (save as Example.xml and put it in the same directory as the compiled example).



Your signature has been erased by a mod please reduce it to no larger than 600 x 120.
Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 9th Mar 2011 18:42 Edited at: 11th Mar 2011 02:10
Hi kaedroho, thanks for this plug-in! It works excellent for loading xml. But, I am having problems in saving xml. I guess I just don't understand how to work the insert commands.

With this example:


For me, it will print out:


Why is it not giving me an opening tag of name "Setup", just only the closing tag ?

It even gives me the same exact result when I try to insert more stuff:



Obviously, I must be doing something wrong

As an example, for the second code example above I would like an xml result of:


Thanks for any help

ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 10th Mar 2011 17:29 Edited at: 10th Mar 2011 17:50
Thanks for reporting this, I'll start digging through the code now.

[EDIT] Looking through the data structures during the save command, it appears that there is no data inside the <Setup> tag. I think I know what the problem is and should have it solved shortly.

[EDIT] Fixed! I will have the update out soon!

Your signature has been erased by a mod please reduce it to no larger than 600 x 120.
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 10th Mar 2011 18:02
Heres the update!

This fixes the problem with adding nodes to elements.

Download:
ZIP
RAR

Your signature has been erased by a mod please reduce it to no larger than 600 x 120.
Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 11th Mar 2011 02:06
Awsome! Thanks man. The code works perfectly now.

ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY
bruceatk
20
Years of Service
User Offline
Joined: 25th Aug 2003
Location: Loudon, NH
Posted: 16th Mar 2011 18:59
Thanks for creating this, i was just getting to the point where I needed this in DB Pro.
Lost Dragon
13
Years of Service
User Offline
Joined: 22nd Aug 2010
Location:
Posted: 17th Mar 2011 02:57 Edited at: 17th Mar 2011 02:58
I'm going to try and use your functions to load Tiled map files over the weekend.

http://www.mapeditor.org/

The tmx format (if you select "store tile layer data as csv" in the preferences) is supposedly just a renamed xml file.
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 10th Jun 2011 15:21 Edited at: 11th Jun 2011 03:05
I think the documentation on this needs a little more work!

for example, in what you posted, you say KD GetXMLFirstChildNode returns nothing, but from the example code it looks like it returns a 1 if successful and a 0 if there is no child node.

Also, a definition of "node" would be nice.

I'm not totally sure what to make of this either. I'd guess that "Document" is the doc type, "element" is a "<foo>" tag, comment is a comment, and text is the abc in "<foo>abc</foo>"? No idea what unknown or declaration are. I'm also a bit worried I'd accidentally read information from a comment into my program after reading that!
[edit]
:\ just after I posted this I found a page about DOM, which I wasn't aware of >.>
right... so... I think that's all I needed. I'll see if I can parse an XML doc!
[edit2]
also, I'm getting a compile time error with "kd getxmlfirstchildnode(xmlid)", and "kd getxmlfirstchildnode xmlid".
:\
"could not understand command at line xx"
[edit3]
Right... it returns a value. "n=kd getxmlfirstchildnode(xmlid)" works fine.


Why does blue text appear every time you are near?
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 11th Jun 2011 11:09 Edited at: 11th Jun 2011 14:55
Alright, I got it.

Here's code that reads an XML document and outputs its structure:


xmlprinter.dba



myxml.txt


Just posting this to help others look at sample code to use the plugin.

Thanks kaedroho! I think now that I got this down, loading data will be a bit easier.

I still have three requests:
Could you make it so that kd xmlgetparentnode returns a 1 if there is a parent node, and 0 if there isn't (if nodetype=0). I've just wrote a function kd_xmlgetparentnode(), because it's more convenient xD

This one I think is pretty necessary: Could you somehow add the ability to jump around from place to place in the tree? Either IDs for locations in the tree, or just stack style push/pop commands. I wanted to add a "print stack" command, that writes the name of all elements that are parents of the current element. That's easy to do with something like:

but then you're left at the root of the tree structure, with no real way to get back to where you were.

It would also be nice to have another debugging command: get xml error line, that would return the line number that the error was on.


Why does blue text appear every time you are near?
Davel_Kerriel
13
Years of Service
User Offline
Joined: 4th Nov 2010
Location:
Posted: 11th Jun 2011 11:52
The pterodactyl is not a dinosaur, but a pterosaur :p
Anyway, thanks to kaedroho for the plugin and thanks to neuro fuzzy for his sample code, it's very helpfull.
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th Jun 2011 11:40 Edited at: 12th Jun 2011 11:40
Quote: "The pterodactyl is not a dinosaur, but a pterosaur :p"

now would be the time to mention creds go to phalaex for the test xml!
http://forum.thegamecreators.com/?m=forum_view&t=179871&b=6

bullet dodged.


Why does blue text appear every time you are near?
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Jun 2011 06:11
Hey now!

WickedVixen
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location: New Brisbane, Utopia Prime, VGC GHQ
Posted: 2nd Jul 2011 02:27
Kaedroho, keep up the great work...
Wonder if I can use XML to hold records of items for a RPG, edit them while game is running, then save it out for level informations, etc.

Here's hoping...

hottap
19
Years of Service
User Offline
Joined: 4th Dec 2004
Location: &amp;FF0
Posted: 6th Jul 2011 17:13
Thanks, Kaedroho.
This is excellent - I have a function which I include to read/write xml but never got round to turning it into a dll, and yours is sooo much faster than mine.
Keep up the good work!
freight hopper
20
Years of Service
User Offline
Joined: 26th Dec 2003
Location: Just beyond the Dunsmuir yard limits
Posted: 14th Jul 2011 07:36
Is the download at the top the most recent? You might edit the other download links that don't work.

Can't wait to try this. Thanks.

kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 14th Jul 2011 22:44
Yep, the downloads at the top are the most recent.

Your signature has been erased by a mod please reduce it to no larger than 600 x 120.

Login to post a reply

Server time is: 2024-03-28 21:17:56
Your offset time is: 2024-03-28 21:17:56