Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Help with XML-Ruby parsers

I've a script in mind that will need to read XML files. I was looking for a XML-Ruby parser. I found these:
REXML (the most used but a 'bit'... sloooow)
LibXML (the fastest one, and my favourite)
Chillkat Libraries (I don't like much these ones)

The problem: I just don't know how to use any of them. Can anyone help me (with LibXML if possible)?


regards
 
You misunderstood me...

What I said:
sayonara-p":32t5oaop said:
I've a script in mind that will need to read XML files. I was looking for a XML-Ruby parser. I found these:
REXML (the most used but a 'bit'... sloooow)
LibXML (the fastest one, and my favourite)
Chillkat Libraries (I don't like much these ones)

The problem: I just don't know how to use any of them. Can anyone help me (with LibXML if possible)?

..........

I've used google for a minute too (so that I said 'I found these'). In fact, I've got it into my project directory.
What I meant is that I just don't know how to import the LibXML library in order to use it in RGSS.
Importing (copy&paste) the LibXML .rb files directly into the RGSS editor throws a lot of errors, like if I've got not all the necessary files or something...
I tried to use 'require' statements too, but it's like RGSS couldn't find these .rb files and it throws an 'no such file' exception.

So I don't know what am I doing wrong. Maybe must I c&p the .rb files in an specific order or the like? I've tried yesterday for a couple of hours but... nothing.


regards
 
Here's how I did it (thanks to this Japanese blog post):

1. Download REXML. The latest version doesn't seem to work with RMXP (probably because it uses features of a newer version of Ruby), so try version 3.1.6 or any earlier version, I can confirm it working with versions 3.1.6 and 3.1.2.

2. Inside the zip file, there's a folder src, and inside it is another folder rexml. You need to extract this rexml folder (src/rexml/) into your game folder (where Game.exe) is. You could optionally put it in another folder (inside Data/ or Data/Scripts/ for example) for better organization, but you'd need to add the path when specifying directory in step 3 or 4.

3. Add this somewhere before you want to use REXML, it adds the current directory ('.') to the list of paths RGSS looks for required scripts in:
Code:
$: << File.expand_path ('.')
I put it in the Main section as soon as the game starts, but it's up to you.

4. Now you could use REXML by requiring rexml/document, like this:
Code:
require 'rexml/document'
Refer to REXML tutorial for information on using REXML. If you need help with that, feel free to ask. I use XML to define poses for my battle and event pose system.

Using any other XML library (or rb file in general) should be similar. I stuck with REXML because it's fast enough for my needs.
 
Really thank, Cowlol, that's what I was looking for :)
The step I didn't know before reading your post was:
3. Add this somewhere before you want to use REXML, it adds the current directory ('.') to the list of paths RGSS looks for required scripts in:
Code:

Code:
$: << File.expand_path ('.')

I put it in the Main section as soon as the game starts, but it's up to you.

I hope this work for LibXML too. Or is REXML not as slow as someone told me?


regards
 
I heard it's slow too, compared to some other libraries and languages. I guess it depends on what you need, my XML files are all small and simple, and I only have to read them once per map/battle, so it works for me. The best way to know for sure is test it yourself, after all.
 
sayonara-p":35cshomm said:
You misunderstood me...

What I said:
sayonara-p":35cshomm said:
I've a script in mind that will need to read XML files. I was looking for a XML-Ruby parser. I found these:
REXML (the most used but a 'bit'... sloooow)
LibXML (the fastest one, and my favourite)
Chillkat Libraries (I don't like much these ones)

The problem: I just don't know how to use any of them. Can anyone help me (with LibXML if possible)?

..........

I've used google for a minute too (so that I said 'I found these'). In fact, I've got it into my project directory.
What I meant is that I just don't know how to import the LibXML library in order to use it in RGSS.
Importing (copy&paste) the LibXML .rb files directly into the RGSS editor throws a lot of errors, like if I've got not all the necessary files or something...
I tried to use 'require' statements too, but it's like RGSS couldn't find these .rb files and it throws an 'no such file' exception.

So I don't know what am I doing wrong. Maybe must I c&p the .rb files in an specific order or the like? I've tried yesterday for a couple of hours but... nothing.


regards

I'm sorry then. But you can't say I misunderstood you... "How to use" is very vague. I'd say you didn't explain yourself good enough.
I guess my 1st post didn't sound too polite, so sorry for that XD.

And btw, if you look at the link I gave you there are comparisons of speed between LibXML and REXML, and LibXML humillated REXML.

Later!
 
Well, it makes sense, considering REXML is written in Ruby and Ruby libxml is a ruby binding of a C library.

With that said getting libxml to work on Windows might prove to be tricky (google "windows ruby libxml") and might require more steps than I outlined because libxml depends on some external libraries while REXML doesn't. If you do manage to get it working, it'd be cool if you share how you did it.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top