Raised This Month: $51 Target: $400
 12% 

[EXTENSION] TinyXml Wrapper


Post New Thread Reply   
 
Thread Tools Display Modes
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 04-08-2012 , 06:26   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #11

Quote:
Originally Posted by Grognak View Post
Hi, is this still supported?
yes it is.

Quote:
Originally Posted by Grognak View Post
I have the following code below, to try to extract the value of a tag in an XML file.
Your code was a bit botched, e.g. you can't return strings like that.
Compare this to yours and learn from it

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <tinyxml>

public OnPluginStart() {
    
RegConsoleCmd("sm_t"CMD_GetTrack);
}

public 
Action:CMD_GetTrack(client,args) {
    new 
String:sTitle[255];
    
GetTrackValue("title"sTitlesizeof(sTitle));

    new 
String:sURL[255];
    
GetTrackValue("permalink-url"sURLsizeof(sURL));

    
PrintToServer("Track Title is: %s"sTitle);
    
PrintToServer("Track URL is:   %s"sURL);
}

stock bool:GetTrackValue(const String:tag[], String:sResult[], maxlength) {
    new 
Handle:hDoc TinyXml_CreateDocument();
    
TinyXml_LoadFile(hDoc"./tf/borked.xml");

    new 
Handle:hRoot TinyXml_RootElement(hDoc); // <tracks>

    
if(hRoot == INVALID_HANDLE) {
        
CloseHandle(hDoc);
        return 
false;
    }

    new 
bool:bResult false;
    
// Get the first <track> inside of <tracks>
    
new Handle:hTrack TinyXml_FirstChildElement(hRoot"track"); // <track>
    
if(hTrack != INVALID_HANDLE) {
        new 
Handle:hEntry TinyXml_FirstChildElement(hTrack);

        
// Iterate over all elements of the <track> element.
        
while(hEntry != INVALID_HANDLE) {
            
decl String:sKey[128];
            
TinyXml_Value(hEntrysKeysizeof(sKey));

            
// if the key matches "tag", return it.
            
if(StrEqual(sKeytag)) {
                
TinyXml_GetText(hEntrysResultmaxlength);
                
bResult true;
                break;
            }

            
hEntry TinyXml_NextSiblingElement(hEntry);
        }

        
CloseHandle(hEntry);
        
CloseHandle(hTrack);
    }

    
CloseHandle(hRoot);
    
CloseHandle(hDoc);
    return 
bResult;

__________________
einmal mit profis arbeiten. einmal.

Last edited by Thrawn2; 04-08-2012 at 06:30.
Thrawn2 is offline
HSFighter
Veteran Member
Join Date: Aug 2007
Location: Flensburg - Germany
Old 05-03-2012 , 14:59   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #12

Hi all,

for the first... Thank you Thrawn2 for this nice Extension

I have a small question:

My XML string is not a file, it's a simple string like this:


Code:
Date: Thu, 02 May 2012 14:18:38 GMT
         Server: Apache
         Vary: Accept-Encoding
         Content-Length: 230
         Connection: close
         Content-Type: text/xml
         
         <?xml version='1.0' standalone='yes'?><headtag>
           <test>STEAM_0:1:101010101</test>
           <b>NO</b>
           <c>YES</c>
           <d>FINE</d>
           <e>DATA</e>
         </headtag>
How can i read the nodes like:

PHP Code:
new String:sTest[255];
    
GetValue("test"sTestsizeof(sTest)); 
??

Thank you for your efforts.
__________________



Sorry for my very bad english
Greetings HSFighter

Last edited by HSFighter; 05-03-2012 at 18:47.
HSFighter is offline
Send a message via ICQ to HSFighter
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 05-04-2012 , 04:31   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #13

you'll need to strip the header no matter what.

after that: currently (as i don't have a method implement to read the xml from a string) you'll need to write it to a file and load it from there
__________________
einmal mit profis arbeiten. einmal.
Thrawn2 is offline
HSFighter
Veteran Member
Join Date: Aug 2007
Location: Flensburg - Germany
Old 05-04-2012 , 11:20   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #14

OK
Thank you
__________________



Sorry for my very bad english
Greetings HSFighter
HSFighter is offline
Send a message via ICQ to HSFighter
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 05-04-2012 , 15:58   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #15

any possibility to rebuild it for Amxmodx ?
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 09-15-2012 , 10:30   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #16

Everyone getting an "Invalid ELF header" error on load: try the attached binary.
Attached Files
File Type: so tinyxml.ext.so (97.3 KB, 259 views)
__________________
einmal mit profis arbeiten. einmal.
Thrawn2 is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 02-22-2013 , 11:49   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #17

[SM] Unable to load extension "tinyxml.ext": .../extensions/tinyxml.ext.so: ELF file OS ABI invalid
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
Meow Mix
Member
Join Date: Mar 2009
Old 07-22-2014 , 08:07   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #18

Is this still supported and working? If so, I want to use it for a plugin...sorry I don't have an environment to test it out at the current moment.
Meow Mix is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 07-22-2014 , 12:13   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #19

It should work, but I don't really support it anymore. Haven't touched it in, basically, ever.
If you run into issues, you might have to compile it on a sane (read as modern) system.
__________________
einmal mit profis arbeiten. einmal.
Thrawn2 is offline
Meow Mix
Member
Join Date: Mar 2009
Old 07-22-2014 , 12:16   Re: [EXTENSION] TinyXml Wrapper
Reply With Quote #20

Thanks Thrawn2. I think what I will do to avoid issues is just have my website do all the parsing and then have SM pull from my website. Little more work, but I think it'll be less problematic in the long run
Meow Mix is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode