![]() |
XML -> Object
To go with the Object -> XML conversion I posted a while back: http://forums.graalonline.com/forums...ad.php?t=74337
PHP Code:
PHP Code:
There are some restrictions. It won't read just any XML file. The XML file has to: Have start and end tags for objects on their own lines e.g. PHP Code:
There is also no error checking. An invalid XML file will get parsed incorrectly and not produce the object you want. Enjoy! -Knight |
Ok, i thought it worked but it doesn't for some reason this wont work:
PHP Code:
Strange. Any ideas? |
Quote:
|
thanks i updated the script in the first post:)
|
Quote:
object.(@ r @ ".foo") = "Test"; Would work I think, but I would say use makevar as Twinny stated |
Yeah, i already fixed it :)
Here's an example: Test.xml PHP Code:
PHP Code:
|
Maybe you could make the tag names customizable so one could shorten the file?
PHP Code:
|
it would be possible, you'd just need 2 arrays, one with names and one with shortened names then have the import/export function look up the shortened/full var name
Although it wont really make that much difference. For simplicities sake it's easier to use the graal var names as the tag names and the problem with that is that you can only import/export specific objects. My XML file was just an example. You could make any XML file you wanted (provided you had the start and end tags on their own lines for objects) with the tags you wanted, of course the variable names when the file was imported would be the tag names from the file. |
What is the advantage of saving vars in XML versus just savevars and loadvars?
|
it will save/load any sub objects recursively.
|
I don't see why they need their own lines...
You could easily loop it all through a string.pos("<") check which isn't every character at all. |
| All times are GMT +2. The time now is 08:08 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.