- NSIS Discussion
- Installer Checks for update using XML
Archive: Installer Checks for update using XML
MichaelFlya
19th May 2005 10:29 UTC
Installer Checks for update using XML
How do I use NSIS to Check for an Update using a XML File?
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <ProgramName>
<version>5.405</version>
</ProgramName>
Lets just say I am Checking something that is Version 5.403
And I use the XML file above Located at a URL Link. It Tells
the Installer that the Most Recent Version is Higher than the
Version Being Installed...
How would I go about this?
-MichaelFlya-
Joel
19th May 2005 14:40 UTC
At this moment there isn't a *official* XML parser plugin for nsis, here, here, are some un-official plugins.
Search the forum and you find other ways to parse a XML, although if your tree only has version as element, try a loop until you find it.
MichaelFlya
19th May 2005 17:45 UTC
Thanks Joel,
Ok to start off how do I call your XML.dll Properly to
Parse it on Node (Version) And Ask if What is Under
the Node is Greater than a Given Number, In this Case
Greater than 5.403 is 5.405, Then Take Action one
way or the other depending on if it ends up Greater or
Lesser.
Lets start at a Line like this... Unless otherwise.
Parse:
XML::TextElementFromNode ${XMLFILE}"ProgramName" "Version"
---
Possibly if OldValue<NewValue Activate "FunctionName"
Other wise Some other Function Gets Activated. Might be
A Type of Fork in the Road for me to Take an Action. Not
that any of my Examples mean anything in the way that
you do it for XML.dll.
-------
I had Read those Links Already actually, I had been
Searching for a while and finally Decided to post ...
-MichaelFlya-
MichaelFlya
19th May 2005 20:14 UTC
Ok well If it Can't than Perhaps Maybe It can be Done With
the one Called nsXML.dll. How would that be Done? And if not
than Where can I get the thing I am Looking for?
-MichaelFlya-
Afrow UK
19th May 2005 21:09 UTC
I used this to get text between two tags in an HTML file, so it should work here too:
http://nsis.sourceforge.net/archive/...ances=0,11,311
-Stu
MichaelFlya
19th May 2005 22:06 UTC
Afrow Uk, (About your Link)
I Have no idea what to do with this... What to change I
mean. Also When I Get it Going to where it Grabs in this
Case in Between <version> & </version> Which Should
return 5.405, How would I say 5.403 is Less than The
text Returned.
Than say if Text Returned is Greater than
5.403 (Call FunctionNameUPDATE) If 5.403
is just Equal to the text Returned it will
than (Call FunctionNameNOUPDATE)
-MichaelFlya-
MichaelFlya
19th May 2005 22:33 UTC
Please Help me Get the Text... And if you want, Also
Please Add how to Check Version Number by Less and
Greater. That would be the next Question Anyway lol.
Attached a Script.
Thanks !!!
-MichaelFlya-
MichaelFlya
20th May 2005 00:58 UTC
Here is the XML to go along with the NSI Script.
-MichaelFlya-
Afrow UK
20th May 2005 11:28 UTC
${GetBetween} "<version>" "</version>" "$INSTDIR\currentversion.xml" "$R0"
${VersionCompare} "$R0" "5.405" "$R0"
StrCmp $R0 0 0 +2
MessageBox MB_OK "Versions equal" IDOK Done
StrCmp $R0 1 0 +2
MessageBox MB_OK "Version one newer" IDOK Done
StrCmp $R0 2 0 +2
MessageBox MB_OK "Version two newer"
Done:
VersionCompare:
http://nsis.sourceforge.net/archive/...s=0,11,122,754
Edit: Make sure you put functions code (from archive pages) in the script before you actually use them.
-Stu
MichaelFlya
21st May 2005 08:05 UTC
Thanks Afrow UK, I am Starting to Get somewhere....
I am Still having Problems... I don't know, I have
attached what I made and Theres still a few bugs. It
seems to Never Retrieve The Value of the XML File
Correctly. So I Changed one of the Lines to test it.
Function VersionCompare is Working Fine Using this.
${VersionCompare} "5.405" "5.403" "$R0"
It also I Guess is only Checking the Last two Digits.
All I know is it Makes 5.405 More than 5.403, But if
I change 5.403 to 5.8 it is less than 5.405 For Some
Reason.
What can be done to make it work with all Digits?
Why Isn't it Grabbing the XML Value Correctly?
-MichaelFlya-
Instructor
21st May 2005 08:25 UTC
I change 5.403 to 5.8 it is less than 5.405 For Some
Reason.
${VersionCompare} "5.405" "5.8" "$R0"
;$R0=1
It's correct. Because
${VersionCompare} "5.10" "5.8" "$R0"
;$R0=1
Right comparison (in your case):
${VersionCompare} "5.4.05" "5.8" "$R0"
;$R0=2
MichaelFlya
21st May 2005 13:01 UTC
I need to add a Decimal every Time after the first Decimal?
When using this Method I must Make my Versions like:
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
-MichaelFlya-
MichaelFlya
21st May 2005 13:27 UTC
As far as Function GetBetween Goes, Using Detail
Print like this:
DetailPrint "$R0"
It Should Return The Version Number of the XML.
But it turns up Blank. I figure once the Code for
that Function is Working Properly I will get a Result
from the XML. This is what I need to have worked
out at the Moment.
Oh and After Function VersionCompare I see it Is
used to say 1 or 2.
-MichaelFlya-
MichaelFlya
21st May 2005 14:17 UTC
Ahh Something Small I have now Figured it out....
${GetBetween} "<version>" "</version>" ".\currentversion.xml" "$R0"
That helped on Returning the Value Found in XML. I must
have not Set the Install Directory. Instead I set OutFile.
But now For Function VersionCompare. Making the Number in
the XML file 5.1 Instead of 5.405 and Doing this with the Line
of Code:
Code:
${VersionCompare} "$R0" "5.0" "$R0"
Everything works When I change 5.0 in the Script to a
more Higher Version than 5.1 it works as I want. Plus
when I change 5.1 in the XML to what ever. So now I
can Work With this. A good Explanation on why it's
best to do 0.0.0.0.0 Decimals is needed but ok to Use.
Both Afrow Uk And Instructor, All I can say is Thanks !!!!
And Joel When ever I need to Write a XML With the
Installer I am sure those Links will Come in handy,
Thanks !!!!
-MichaelFlya-