last day (14 days later) » 

1:47 PM
0
Q: Inno setup: Extract XML node and show it

DeXonI need some help: I have the following code and I want to extract it into a plain text but I cannot manage to do it. The code works but what I need is to show it in the ExpandConstant field. I have tried several ways but no luck so far. function LoadValueFromXML(const AFileName, APath: strin...

 
XML format does not know lines. It has nodes. But anyway, are you asking how to get the whole node text, such as <node>Value</Node> ?
 
Ok, I didn't know that, but yes I want the value of that node <info><patch_info_urls><item>this value</item></patch_info_urls></info>
 
Just for being sure if I got your requirement (since I can't imagine the usage of the whole node text). Do you want to get just a value of that node, in your example this value. Or the whole node text (which is what I think you're asking) <info><patch_info_urls><item>this value</item></patch_info_urls></info> ?
 
Only "this value", I don't need the whole node text.
 
Well, then the code that you've posted should work to get the first URL of that patch_info_urls URL list (assuming the XML we are talking about is many times mentioned in the WOT forum threads; I don't know its format personally).
 
1:47 PM
Yes, the code works but I'm trying to show it in "Caption" and that's what I don't know how to do it. (the code is this one: pastebin.com/skEKa89p)
 
Sorry, but I don't understand. What is the Caption ? Is your question even related to reading from XML then (if the code for reading works) ? Please edit your question and elaborate what is your aim; extract it into a plain text is far too broad.
 
I edited the first post and title so that you can understand better what I need.Thanks.
 
Hi there!
Are you sure that you need to have it expandible through ExpandConstant ?
StaticText.Caption := LoadValueFromXML('C:\Games\World_of_Tanks_test\WoTLauncher.cfg', '//info/patch_info_urls/item');
would do it well...
 
2:14 PM
I tried all options except for that one
I am sorry for not having been clear enough
Thanks
 
You're welcome! But there can be situations where you may need to use the ExpandConstant function. For example if you'd like to, I don't know, display the computer's user name followed by that XML node value.
In that case you would write e.g.:
var
...
URL: string;
begin
...
URL := LoadValueFromXML('C:\MyFile.xml', '//node/subnode');
StaticText.Caption := ExpandConstant(Format('{username} %s', [URL]));
end;
It works as that the line:
Format('{username} %s', [URL])
inlines the URL variable into the string, so it returns something like:
and this string is then processed by the ExpandConstant which inlines the user name to the final string, so it produces something like:
'MyUserName update.worldoftanks.com'
But if you are not using built-in constants in the text that you want to display, then you don't need ExpandConstant.
 
I was trying something similar to that right now
Another question: could I give a value to that URL (since there are several URL) to change the URL for a text?
Would it work with an IF function?
 
2:34 PM
Could you elaborate ? "give a value to that URL" makes no sense to me, "change the URL for a text" neither.
 
Ok. I want to show a text X if an URL.com is detected, and a text Y if URL.es for example.
something like this pastebin.com/9dJVAr5s
 
2:53 PM
Might be like this pastebin.com/XRUGPDTt
P.S. as I already mentioned, there's no need to use ExpandConstant for strings that does not contain built-in constants.
 
Perfect! That's what I'm looking for. Thanks but now I get an error
http://i.imgur.com/pMJTP2p.png
Don't worry about the error. I put : instead of ;
 
3:12 PM
OK. You're welcome!
 
3:30 PM
I have to go now. See you!
 
3:45 PM
See you! :D
 

last day (14 days later) »