I've seen CXmlManager class in CMlScript called XML. It would be cool to save XML files into media folder with data of choice.
Homever there isnt some kind of Save function there.
So, how is this class useful? I heard that its used in gamemodes.
Thanks for answer.
CXmlManager (XML) class?
Moderator: English Moderator
- BigBang1112
- Posts: 389
- Joined: 20 Jul 2015, 12:44
- Manialink: bigbang1112
- Location: Czech Republic
- Contact:
CXmlManager (XML) class?
Creator and competent racer. YouTube Discord
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
- Dommy
- Translator
- Posts: 1901
- Joined: 25 Aug 2011, 21:45
- Manialink: exchange
- Location: Poland
- Contact:
Re: CXmlManager (XML) class?
Check the manialink exchange and press Ctrl + G twice, search for githubusercontent.com or dominolink.aq.pl and see how it's used (a lot).
Ryzen 7 2700X, GTX 1070 Ti, 16 GB RAM, Windows 10 Insider Build
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT
Contact me via GALAXY & PURSUIT DISCORD
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT
Contact me via GALAXY & PURSUIT DISCORD
- BigBang1112
- Posts: 389
- Joined: 20 Jul 2015, 12:44
- Manialink: bigbang1112
- Location: Czech Republic
- Contact:
Re: CXmlManager (XML) class?
i checked it and there is no text after Ctrl+G twicedomino54 wrote:Check the manialink exchange and press Ctrl + G twice, search for githubusercontent.com or dominolink.aq.pl and see how it's used (a lot).
edit: i understand now trying to find the usage tho
Creator and competent racer. YouTube Discord
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
Re: CXmlManager (XML) class?
In short: you use the CXmlManager to read XML. I don't know if gamemodes can read local XML config files, but other than that it is widely used to read XML from APIs.
When you have a look at the documentation, you will get how to use it.
Quick example:
When you have a look at the documentation, you will get how to use it.
Quick example:
Code: Select all
// create document
declare CXmlDocument Document = XML.Create(ApiResponseString);
declare CXmlNode Root = Document.Root;
// iterate over items
declare i = 0;
foreach (Node in Root.Children) {
// Just a little (useless) example on what to do with the data
MyLabels[i].Value = """TagName: {{{Node.Name}}}, Attribute 'data': {{{Node.GetAttributeText("data", "not set")}}}""";
i += 1;
}
Re: CXmlManager (XML) class?
i would use log instead of labels for this example
You might want to check my tutorial about this topic:
viewtopic.php?f=279&t=29396&p=234419#p230480
You might want to check my tutorial about this topic:
viewtopic.php?f=279&t=29396&p=234419#p230480
Re: CXmlManager (XML) class?
Yes it's possible with the Http API using a file:// address instead of a web url.zocka wrote:I don't know if gamemodes can read local XML config files
Code: Select all
declare Request <=> Http.CreateGet("file://Media/Path/To/My/File.xml", False);
- BigBang1112
- Posts: 389
- Joined: 20 Jul 2015, 12:44
- Manialink: bigbang1112
- Location: Czech Republic
- Contact:
Re: CXmlManager (XML) class?
Code: Select all
declare CXmlDocument xmlFile;
xmlFile.TextContents = Http.CreateGet("file://Media/Path/To/My/File.xml", False).Result;
This would be cool to use.
Creator and competent racer. YouTube Discord
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
Re: CXmlManager (XML) class?
Just declaring xmlFile will result in xmlFile being Null and thus not having the property TextContents.BigBang1112 wrote:If I understand this right, these 2 line above will work and read the file as CXmlDocument?Code: Select all
declare CXmlDocument xmlFile; xmlFile.TextContents = Http.CreateGet("file://Media/Path/To/My/File.xml", False).Result;
You create CXmlDocument objects with Xml.Create(xmlString).
Http Requests only work asynchronously to my knowledge, so you would need something like shown below, but you can try it
Code: Select all
declare CXmlDocument xmlFile;
...
declare CHttpRequest RequestToLocalFile;
declare Boolean RequestToLocalFilePending;
...
RequestToLocalFile = Http.CreateGet("file://Media/Path/To/My/File.xml", False);
RequestToLocalFilePending = True;
...
while(True) {
yield;
if (RequestToLocalFilePending && RequestToLocalFile.IsCompleted) {
RequestToLocalFilePending = False;
if (RequestToLocalFile.StatusCode == 200) {
xmlFile = Xml.Create(RequestToLocalFile.Result);
doSomethingWithTheData(xmlFile);
} else {
log("probably local file was not found");
}
Http.Destroy(RequestToLocalFile);
}
}
- BigBang1112
- Posts: 389
- Joined: 20 Jul 2015, 12:44
- Manialink: bigbang1112
- Location: Czech Republic
- Contact:
Re: CXmlManager (XML) class?
Oh I see it there.
You need to wait when the file will fully load/download. I want to use it in a titlepack, not default manialink on the internet.
So when reading a file with HttpRequest which isnt on the internet, you will need to wait before it load?
And yeah, I forgot on that Create function.
Thanks for rich answer!
You need to wait when the file will fully load/download. I want to use it in a titlepack, not default manialink on the internet.
So when reading a file with HttpRequest which isnt on the internet, you will need to wait before it load?
And yeah, I forgot on that Create function.
Thanks for rich answer!
Creator and competent racer. YouTube Discord
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
- ENVIMIX (out in open-source)
- Challenge (OUT NOW)
- Leaderboards (OUT NOW)
- Compute Shadows
Who is online
Users browsing this forum: No registered users and 0 guests