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.

DarkBASIC Professional Discussion / MadBit - XML Plugin

Author
Message
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jan 2013 06:52
Hi, I believe your XML plugin thread is locked.

Your plugin is my favourite so far.

Is there any chance of you adding a feature to load an XML document from a string. In other words, parse it from a string. I have documents being downloaded over a network. Any hard drive access is always best avoided during the running of a CPU intensive game.

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Jan 2013 10:20 Edited at: 25th Jan 2013 12:53
Why do you not open the file before the game starts. All access to an element of the xml-file happens only in memory not to the hard drive.

And, nice to hear that someone used my plugin.

EDIT:
But anyway, i implement it now. you can download the new version in the original thread or here. Is now a undocumented function called XML PARSE DOCUMENT docID, xmlString$ in the download-file you have a new example, dll-file and keyword-file.

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jan 2013 15:23
Wow fast. The reason why is because not all xml exists on the hard drive. Sometimes it comes from the user or a server.

Well done. Will try it out. This is the best xml plugin.

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 26th Jan 2013 01:16
Jumping on here in case this works for me too!

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Jan 2013 09:42
Hi MadBit, do you want me to make individual requests like this or should I just make one list of requests in one go?

A thing that would be nice is to get the child element of a given index without having to loop through them all. I have to select tags by their index, You don't always know the name of the tags.

XML GET CHILD ELEMENT FromElement, [ChildIndex], ToElement

Example:


No big rush, for now I am looping through all of the elements until I reach a requested id, but this is slow.

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 28th Jan 2013 10:35 Edited at: 28th Jan 2013 10:35
Quote: "Hi MadBit, do you want me to make individual requests like this or should I just make one list of requests in one go?"

Make rather a list. Then I do not make a new release after every added feature.

Quote: "No big rush, for now I am looping through all of the elements until I reach a requested id, but this is slow."

I would not do differently. I don't know whether this is much faster, if the function is sitting in the plugin or not.
I recommend you to reconsider the structure of the xml file. If you have influence on it.
I think your file shows like this.
<player>
<skateboard attrib="value" .../>
<inlineskates attrib="value" .../>
...
</player>

And i think it is better so.
<player>
<item name="skateboard" id="0" attrib="value" .../>
<item name="inlineskates" id="1" attrib="value" .../>
...
</player>
That's just a guess, and a suggestion. I don't know the structure of your xml-file and how you use it.
If you really want this feature in the plugin i can implement it. But I doubt the convenience of this function.

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Jan 2013 15:21 Edited at: 28th Jan 2013 15:28
I see.

Ok, so say I have 10000 xml items, what would you do to get to item 8582?

REPEAT : XML GET NEXT ELEMENT(n, n) : If XML GET INTEGER ATTRIBUTE(n, "id") = 8582 Then DoAction() : Exit
Inc id : Until id => Count

is that what you want me to do with the ID attribute?

I don't know how your plugin works, I thought it was similar to an array of elements; eg: I thought you could return Element(8582) as if it was an array.

But if that is not the case, forget it; the whole point of asking for it was because I thought your elements where numbered in an array.

Since that is not the case, I'll have to store all the XML file elements into memory: EG: XML GET NEXT ELEMENT n, ElementArray(id) so I can quickly access any element ID. So for example, say I create a listbox of items, each icon would have its own XML element pointer.

Quote: "I don't know the structure of your xml-file and how you use it."


Yeah some of it is HTML, some of it is from other programs, some from a database and I might also read xml based .OBJ later on. So, I can't always change the structure.

Quote: "I think your file shows like this.
<player>
<skateboard attrib="value" .../>
<inlineskates attrib="value" .../>"


I just gave a very simple example, in reality my XML can look like anything, but not XML from other sources such as HTML. So I like was saying I can't currently access a specific element index without loading them all as it stands. I'd have to use Styx or VB.NET Linq to handle situations where I'd need to query long XML files for specific entries via their node index.
Thanks.

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 28th Jan 2013 20:12
Ok, this is very huge. I wrapped only the TinyXML library for DBPro and this one stores the elements in a linked-node-list. Also if i implement your feature then i must walk the branch to that position. Maybe, i can rewrite some critical sections to store internally the elements in arrays but this will take time and lot of work.

But can you be sure that the xml-file is not changed? If some one insert an element than your item 8582 can appear on another position. And you will not find the element there what you had there before.

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 29th Jan 2013 06:08
If it is not easy to add, then it might not be worth it if you are in the same position I am in; I thought it was possible because the other plugins can do it.

If you have to walk the branch, then it makes no difference to me walking the branch in DBP. I thought that you had an array of child elements with numeric indexes like in .NET. So I am guessing XML COUNT CHILDS() literally counts each element one by one?

Quote: "If some one insert an element than your item 8582 can appear on another position. And you will not find the element there what you had there before.
"


It's my server, so only a hacker would be interested in doing that. The server is MySQL based and communicates either via XML or HTML. I will use .NET or PHP for long XML queries.

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 29th Jan 2013 09:23
Quote: "So I am guessing XML COUNT CHILDS() literally counts each element one by one?"

I'm afraid so. That does tinyxml.
Even more I think about it, it seems to me be a good idea to make a few changes.
If you have more suggestions please tell me.

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 29th Jan 2013 10:17 Edited at: 29th Jan 2013 10:24
I still like the plugin. It is a primary means of communication between a certain process. Being small and streamlined is a good thing.

Also the parse XML text function was really important for me because a number of processes communicate to DBPRO via strings, this saves me alot of parsing work.

Suggestions
I think more real world ideas will come the more I use the plugin, but for now any ideas are guesses at best, maybe worth waiting a while. But if you feel like it, here are some;

A few minor suggestions;

a
I think one might want to return or set 64bit variables (DOUBLE INTEGER / DOUBLE FLOAT ). I use Double Integers for bit sets.
But at the moment, I am not needing to store 64bit variables in the database, but who knows.

XML SET/GET DOUBLE INTEGER ATTRIBUTE | XML GET/SET DOUBLE FLOAT ATTRIBUTE perhaps; but if IntVal( XML GET ATTRIBUTE(n) ) is the same thing, then no need for it.

b
Again very trivial, the word 'CHILDS' is not proper in this context; it is one of those words. I don't personally mind because I am more interested in the fact that it works, but just so you know:

XML COUNT CHILDS should be XML CHILD COUNT, XML COUNT CHILD ELEMENTS or XML COUNT CHILDREN. 'Count children' literally states that it is counting them one by one. 'Child count' is more of a noun (name) of data representing a pre-determined count. But either will do.

'Childs' isn't in the dictionary. The closest you can find is "Child's", EG: He has a child's mentality.

Question?
Should an element with text but no child nodes return 1 with XML COUNT CHILDS()?

The following code returns 1 child



even though it is text. Is text a valid child node? It isn't all that bad if it is or isn't, just wondering.


Billboards
I am using your billboards plugin for my character labels, stay tuned for my next game update which should show it in use, via my banner in a few days.

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 29th Jan 2013 13:25
Quote: "XML COUNT CHILDS should be XML CHILD COUNT, XML COUNT CHILD ELEMENTS or XML COUNT CHILDREN. 'Count children' literally states that it is counting them one by one. 'Child count' is more of a noun (name) of data representing a pre-determined count. But either will do.

'Childs' isn't in the dictionary. The closest you can find is "Child's", EG: He has a child's mentality."

English is not my natural language and i know my English is poor (but Google-translator help me ). By the next Release i will change this. Thank you for this hint.

Quote: "Question?
Should an element with text but no child nodes return 1 with XML COUNT CHILDS()?

The following code returns 1 child

+ Code Snippet

even though it is text. Is text a valid child node? It isn't all that bad if it is or isn't, just wondering.
"

yes that is as you have thought. the text is a own child-Node.This is how tinyXml Handle all nodes.
you can see it here


Quote: "Billboards
I am using your billboards plugin for my character labels, stay tuned for my next game update which should show it in use, via my banner in a few days."

cooool

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 29th Jan 2013 16:02
Quote: "English is not my natural language and i know my English is poor"


It is nothing major, just letting you know before you make a new release. Ironically, your plugin's good english is one of its main strengths.

Quote: "the text is a own child-Node.This is how tinyXml Handle all nodes."


I understand

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 29th Jan 2013 19:49
Quote: " Ironically, your plugin's good english is one of its main strengths.
"

HeHe, thank you . I've spent more time for writing the documentation as for the plugin it self .

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Ruwbaen
14
Years of Service
User Offline
Joined: 30th Dec 2011
Location: Cyberspace
Posted: 2nd Feb 2013 01:04
I can't get the function XML REMOVE ELEMENT to work. The code is like:

XML OPEN DOCUMENT "test.xml",1
XML LOAD DOCUMENT 1

XML GET ROOT ELEMENT 1,1
XML GET ELEMENT 1,"test1",2
XML REMOVE ELEMENT 2

XML SAVE DOCUMENT 1
XML CLOSE DOCUMENT 1

I just can't get it to work, am I doing something wrong?

"Ce n'est pas un bijou normale monsieur Will" - Chaque Dupont in my game Jack Will
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 4th Feb 2013 11:30 Edited at: 4th Feb 2013 11:31
Thanks for pointing to this. It has been shown that was a wrong connection in the command-table.
Here is the fixed release.
xml-plugin
The Original thread is updated.

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 5th Feb 2013 21:23
Hi, what's up.

What does XML Load Document do? Based on the document ID, does it store a reference to the XML file name or does it store the XML document in memory in raw form? Or something?

Thanks

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 6th Feb 2013 08:17
Hi,
XML LOAD DOCUMENT loads/store the entire xml-file in memory and generate a linked-node-list.

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 7th Feb 2013 01:03
I see. So XML OPEN DOCUMENT stores information about the file in order for Parse/Load to work?

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 7th Feb 2013 08:18
Correctly!

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 8th Feb 2013 18:18 Edited at: 8th Feb 2013 18:20
Hi, how do I put an xml element into a string to be sent over the network?

Or did I only just spot a missing function.

I send the xml over the network to a string, and parsed it. Now I need to send it back over the network. Note, that what is being sent is a NEW xml element, created from XML commands; it is currently not a string.

For now I will have to write the xml to the disk, then load it as a string, then send it over the network; but that is not ideal for FPS.

If there is no way, then in any future update; please provide XML ELEMENT TO STRING or XML GET ELEMENT$.

Take care

MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 11th Feb 2013 09:57 Edited at: 11th Feb 2013 10:05
Hmmm, this is a spacial case. Normally a xml-file is used for saving states and configurations. In your case you send and receive real time game-data. I don't know if this a good idea. I think it is better to send/receive more compressed data. An xml-string has too much overhead and heavily used the connection.

But if you want to do this absolutely so, then you can use the following code.

If you know your element has no children, then you can remove the recursive part of the function. if you need the recursive part, then be careful that you not using element-id's after the specified parameter 'recursiv'.
I hope I could help a little.

Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 11th Feb 2013 13:39
Thanks for that, that was helpful. I have an ID system (Matrix1 Freelists) so recursion will be handled safely.

Quote: "Normally a xml-file is used for saving states and configurations."


It is also used for content delivery procedures such as XAML, AJAX, RSS and HTML.

Quote: "I don't know if this a good idea. I think it is better to send/receive more compressed data. An xml-string has too much overhead and heavily used the connection."


Compression is applicable in some situations, but useless in mine. Some of the network runs between local interface controls that can only communicate with your plugin with strings or files.

An example of interface elements is a document or a datagrid; the main feature of these controls is that they interpret XML.

Although your plugin has the XML ready, the others cannot communicate with it directly, I must send it as a string or write it on the hard drive.

I also need to check XML for authenticity; checking for hacks. Some ASCII characters sent to a MySQL database can screw it up.

Login to post a reply

Server time is: 2026-07-07 00:49:17
Your offset time is: 2026-07-07 00:49:17