New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add xmlLoadString function #809
Conversation
What happens if someone calls xmlSaveFile on this node? |
I'm going to look at this shortly - I'll ensure that file-related XML functions do not work with xml-nodes created via xmlLoadString |
This should now be fixed. function init()
print("Loading XML String [client]")
local rootNode = xmlLoadString("<animals test='x'><monkey name='crosroad'></monkey> <turtle name='luxy'></turtle></animals>")
if rootNode then
print("Trying to save non-file XML node")
local saveXML = xmlSaveFile(rootNode)
print("xmlSaveFile Result:", saveXML)
print("Trying to unload non-file XML node")
local unloadXML = xmlUnloadFile(rootNode)
print("xmlUnloadFile Result:", unloadXML)
end
end
addEventHandler("onClientResourceStart", resourceRoot, init) Both will return false in the above example. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The iterator/index value of the loop within I have, however, cleaned up the loop in Aside from this, everything seems to be working great. |
Fixed some issues brought to my attention by @patrikjuvonen XML strings are now properly parsed, to iterate through all children (instead of just the 1st) Also added checks for broken XML strings, and error outputting |
Waits for #821 to solve. |
@patrikjuvonen I don't think this should be assigned to 1.5.7 |
I've moved it to backlog now. We should probably check what else is left in 1.5.7 milestone and move them elsewhere if unlikely to get them completed in time. |
The decision in pull request #821 (Pin down return value on failure) is now settled. |
Co-Authored-By: Lpsd <40902730+Lpsd@users.noreply.github.com>
Ensures that XML file functions (xmlSaveFile, xmlUnloadFile) do not work with XML nodes created without a file (via xmLoadString) and returns correctly to reflect this.
Co-Authored-By: LopSided <lpsd@users.noreply.github.com>
Cool, thank you! |
Currently, if you want to read XML data that is compatible with the other xml* functions, you need to create a file with the XML data (using
fileCreate
), then read that file usingxmlLoadFile
This will allow you to read XML data via string using
xmlLoadString(xmlString)
Example (client):
My only concerns in this commit are the following (someone who actually knows what they are doing should verify this):
Shared/XML/CXMLNodeImpl.cpp:17
Shared/XML/CXMLNodeImpl.h:62
First time looking into MTA's code, and hardly worked with C++ too, so let me know of anything dumb in my commit!
Note: I have been made aware of a branch which is ready to test, pugixml, so more than anything I am hoping this PR will speed that process up ;)