SA-MP Forums Archive
[Plugin] [REL] XML loader - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] [REL] XML loader (/showthread.php?tid=150755)

Pages: 1 2 3


XML plugin - Zeex - 27.05.2010

A very basic plugin that allows you load XML documents and extract data from them using XPath expressions. It is based on pugixml parser/loader by Arseny Kapoulkine.


The following functions are provided:


Usage example


pawn Код:
#include <xml>


// somewhere...

// Open file example_account.xml
new XML:xml = xml_open("example_account.xml");

// Check whether it was opened
if (xml)
{
    new buf[100];

    // Get some data...
    xml_get_string(xml, "player/profile/sex", buf);
    printf("sex=%s", buf);
    printf("age=%d", xml_get_int(xml, "player/profile/age"));
    printf("x pos=%f", xml_get_float(xml, "player/ingame/saved_position/x"));
    printf("y pos=%f", xml_get_float(xml, "player/ingame/saved_position/y"));
    printf("z pos=%f", xml_get_float(xml, "player/ingame/saved_position/z"));
    xml_get_string(xml, "player/ingame/weapon[@ammo>100]/@name", buf);
    printf(buf);

    // Close when finished working
    xml_close(xml);
}
example_account.xml:
Код:
<?xml version="1.0"?>
<player>
	<profile>
		<password>asdf8s9ad7f2</password>
		<sex>male</sex>
		<age>18</age>
	</profile>
	<ingame>
		<saved_position>
			<x>123.456</x>
			<y>9871.8712</y>
			<z>3.000</z>
		</saved_position>
		<money>100000</money>
		<weapon name="Deagle" ammo="60" />
		<weapon name="Minigun" ammo="5000" />
		<weapon name="Chainsaw" ammo="0" />
	</ingame>
</player>
Downloads



Re: [REL] XML loader - [03]Garsino - 27.05.2010

Nice work, I might try it out, but I don't know what I can use it for. Any ideas?


Re: [REL] XML loader - Calgon - 27.05.2010

Excellent! I'm going to be able to use this as an RSS feed in-game.

Nice work!


Re: [REL] XML loader - Fj0rtizFredde - 27.05.2010

Sweet


Re: [REL] XML loader - Zeex - 27.05.2010

Quote:
Originally Posted by [03
Garsino ]
Nice work, I might try it out, but I don't know what I can use it for. Any ideas?
Added example, see the first post


Re: [REL] XML loader - [03]Garsino - 27.05.2010

Quote:
Originally Posted by Zeex
Quote:
Originally Posted by [03
Garsino ]
Nice work, I might try it out, but I don't know what I can use it for. Any ideas?
Added example, see the first post
O, very nice


Re: [REL] XML loader - Jay_ - 27.05.2010

Brilliant!


Re: [REL] XML loader - bpeterson - 27.05.2010

Awesome work, good job!


Re: [REL] XML loader - lolumadd - 27.05.2010

Amazing release man.


Re: [REL] XML loader - lolumadd - 27.05.2010

Actually, I get an error that a .dll is missing from my computer when I start my samp-server with the plugin.


Re: [REL] XML loader - Zeex - 28.05.2010

Quote:
Originally Posted by lolumadd
Actually, I get an error that a .dll is missing from my computer when I start my samp-server with the plugin.
What's the text of error you are getting? If the server says "Failed" when trying to load it make sure you copied .dll to server_folder/plugins/ and added it to server.cfg


Re: [REL] XML loader - TruServe - 28.05.2010

Looks great, will be very useful if people want to retrieve character information from the XML file and display the info via PHP, I'm going to have to try everything out


Re: [REL] XML loader - Calgon - 28.05.2010

Now there's JSON and XML plugins/includes, awesome.


Re: [REL] XML loader - lolumadd - 28.05.2010

Quote:
Originally Posted by Zeex
Quote:
Originally Posted by lolumadd
Actually, I get an error that a .dll is missing from my computer when I start my samp-server with the plugin.
What's the text of error you are getting? If the server says "Failed" when trying to load it make sure you copied .dll to server_folder/plugins/ and added it to server.cfg
The program can't start because MSVCR100.dll is missing from your computer. Try reinstalling the program to fix this problem.


Re: [REL] XML loader - RyDeR` - 28.05.2010

Awesome work there


Re: [REL] XML loader - ViruZZzZ_ChiLLL - 29.05.2010

OMG, this is really, really awesome Zeex!


Re: [REL] XML loader - Zeex - 29.05.2010

Quote:
Originally Posted by lolumadd
Quote:
Originally Posted by Zeex
Quote:
Originally Posted by lolumadd
Actually, I get an error that a .dll is missing from my computer when I start my samp-server with the plugin.
What's the text of error you are getting? If the server says "Failed" when trying to load it make sure you copied .dll to server_folder/plugins/ and added it to server.cfg
The program can't start because MSVCR100.dll is missing from your computer. Try reinstalling the program to fix this problem.
OK, I compiled it with statically linked CRT and tested on another PC which has no MSVCR100.dll, re-download please and let me know is it alright


Re: [REL] XML loader - xomka - 29.05.2010

nice job

не будет глючить с слишком длинными XML?


Re: [REL] XML loader - Rac3r - 29.05.2010

Very useful plugin, nice release Zeek


Re: [REL] XML loader - lolumadd - 29.05.2010

Quote:
Originally Posted by Zeex
Quote:
Originally Posted by lolumadd
Quote:
Originally Posted by Zeex
Quote:
Originally Posted by lolumadd
Actually, I get an error that a .dll is missing from my computer when I start my samp-server with the plugin.
What's the text of error you are getting? If the server says "Failed" when trying to load it make sure you copied .dll to server_folder/plugins/ and added it to server.cfg
The program can't start because MSVCR100.dll is missing from your computer. Try reinstalling the program to fix this problem.
OK, I compiled it with statically linked CRT and tested on another PC which has no MSVCR100.dll, re-download please and let me know is it alright
Thanks it works now! Anyways, would using .xml be any faster than using a .cfg and using file functions?