Archive: nsisXML: XML reader for Nsis


nsisXML: XML reader for Nsis
Ok!

Once again, from scratch, a plugin to read(for the moment) some XML elements attributes and text.

See example.

Note: is a debug state but stable...


:up:

-daz


A couple of suggestions:
a) Include the source code, so that the rest of us can help.
b) Add support for XPath.


it does not work.
refuses to find the file i want him to read.
the following code gives me a "system cant find the file" error:


IfFileExists "$OUTDIR\Mods\$R0\mod.desc" +2
Abort
nsisXml::Tidy "$OUTDIR\Mods\$R0\mod.desc"


this code even crashes the program:

IfFileExists "$OUTDIR\Mods\$R0\mod.desc" +2
Abort
nsisXml::GetElementText "$OUTDIR\Mods\$R0\mod.desc" "title"


and i'm 1000% sure, the file exists.

@iceman_k: I'll make some improvements..later...now, for the XPath..don't kow yet..

@Comm@nder21: I'm using firts version of msxml... maybe try using .xml & fix the path, there's a reason for system cant find the file


the path IS fixed, i also tried with .xml ending ...
this plugin does not work.

the older xml plugin from lobo lunar (they told me that youre the same :)) works fine for me, though its 44k ...


(out of topic) Comm@nder21, your links in your signature are pointing to wrong wiki pages.

I'm using firts version of msxml...
So that means, you're using the first version launched of the parser instead of the newest? Or maybe I'm overlooking this?

Well... I'm making adjustmens... I'll check that part.
@deguix: Is the installed version 1.0, which comes with IE 4, using new stuff, requires that the end-user must have the newest msxml version.


Originally posted by iceman_k
A couple of suggestions:
b) Add support for XPath.
Ok :)

Seems that XPath will be teh* way :D
Working on it :winamp:

Let's give another chance ;)


thx, deguix, ill fix them asap.
but plz, send me a pm in such things instead of posting anywhere in the forums :D

joel, i'll try your new version asap.


plugin is shit.

why?
1. unicode seems not to be supported. i get lots of errors with characters like -äöü/ in this format:

<title>ti-tle</title>

using code from the examples (text())

2. though you say, "use xpath syntax", no xpath functions are supported.
text() is no xpath function, but e.g. normalize-space() is.
(according to the page linked to in readme)
gives me just errors ...


well, if you manage to fix this two major issues, the plugin is quite usable.

what i just hate, is the requirement of the msxml4 parser, that weights over 700k!


Comm@nder21:

I can't make a plugin that is "usable" just for you. The unicode is not my fault. I got feedback from another users and they say that the plugin works great, even on Win98. There are another ways to parse an xml... I'm just making an average plugin for a common and easy xml file (including for non-programmers users). I don't see why not to update to msxml4... you update your windows, right?


i do.
but it has to be installed manually even on my winxp sp2 (it's not provided with windows update).
and this is the problem:
anyone that wants to use the program has to install this 700k package first ...

i'm sry, i didn't want to sound that rude, but i can't get it working really :)

of course, the parser is great, but i can't make it using any of the w3c conform functions.
just your (non-w3c) text functio works...


but i can't make it using any of the w3c conform functions.
just your (non-w3c) text functio works...
ah... that's a whole another history ;)

Basically you can either choose between using a very basic non-validating XML parser (which will fit into a few kilobytes) or a full-featured W3C complient parser (like MSXML) with support for namespaces, schemas and additional technologies.

Maybe it would be a good idea to create a NSIS plug-in for both situations.


what about:
http://nsis.sourceforge.net/wiki/XML_manipulation_(based_on_MSXML)
?


(There is currently no text in this page)
:rolleyes:

http://nsis.sourceforge.net/wiki/XML...ased_on_MSXML)

-Stu


sorry, the forum did not recognize the URL correctly
here it is:
http://nsis.sourceforge.net/wiki/XML...ased_on_MSXML)


Beta version ( do not overwrite or replace with the other version!!!)
Ok...

I'm working in this re-build version of nsisXML.
Test the example and tell me if you got errors...

Note: it suppose to work with OS that have msxml2 parser... so Win98 might have it pre-installed...


Another big update:

nsisXML plugin to create and parse XML files using MSXML 2.6 (hope Win98 and better have it)

Instructions:
- Copy nsisXML.dll to Plugins and nsisXML.nsh to include directories
- Read this readme and example files.

Functions:

==[Build]==
Displays the build version of the plugin.

Example:
${nsisXML->Build} ${VAR_RET}

==[xPath]==
Uses xPath syntax to parse and get strings from elements or attributes values.

Example:
${nsisXML->xPath} "PATH_OF_XML_FILE" "XPATH_INSTRUCTION" ${VAR_RET}

==[Create]==
Creates, in memory, the template of the xml file.

Example:
${nsisXML->Create}

==[CreateElement]==
Let's you create a xml element, from the parent document or from another node.

Example:
${nsisXML::CreateElement} "XPATH_INSTRUCTION" "STRING_ELEMENT"

Note:
use "XPATH_INSTRUCTION" to locate a node where to put the new element; empty param means
the element will be as the first child.

==[CreateComment]]==
Well...creates a comment after an element.

Example:
${nsisXML->CreateComment} "XPATH_INSTRUCTION" "STRING_COMMENT"

==[SetElementAttr]==
Adds an attribute and its value to an element.

Example:
${nsisXML::SetElementAttr} "XPATH_INSTRUCTION" "Attribute" "Value"

==[SetElementText]==
Sets the text for an element.

Example:
${nsisXML->SetElementText} "XPATH_INSTRUCTION" "STRING_TEXT"

==[Display]==
Shows in a MessageBox How's your xml tree going.

Example:
${nsisXML->Display}

==[Release]==
Frees the memory from the xml template and save the xml into a file.

Example:
${nsisXML->Release} "$EXEDIR\myxml.xml"


pre-release (build 1.0.3)
Another changes and bug fixes... see the readme and the examples...


In your attached archive: nsixml.nsh should be named nsisxml.nsh

Also, trying to compile example 1 (included with the package) fails with:

PHP Code:


File:"nsisXML.dll"->"$PLUGINSDIR\nsisXML.dll"***91;compress***93;23575/65536bytes
PluginCommand
:Build0
DetailPrint
:"Buildversion:$0"
Invalidcommand:${nsisXML->xPath}
Errorinscript"C:\DocumentsandSettings\Administrator\Desktop\stripped\exampe-1.nsi"online17--abortingcreationprocess

Full log attached. Still, I like the idea. Thank you for writing this!

In your attached archive: nsixml.nsh should be named nsisxml.nsh
That type was fix and is going to publish in the next, and final prerelease :D
Also, trying to compile example 1 (included with the package) fails with:
Ok...I read you error log....and seems that you missed to include in the same folder one of the xml's.
In a few moments I'm going to post the final prerelease... :)

pre-release (build 1.0.4)
Final preRelease... see the help file and the examples
Almost there!

Any suggestions are welcome :D


Well... plugin uploaded into my site :)

Thanks for the people who test it :up:


nsisXML (build 1.0.5)
Ok.. the plugin is updated, the only new thing that the CreateElement function can tidy-up... :D

TODO:
1.- Tidy on LoadXML
2.- Remove Attribute param.

:)


great work man, thanx :)

attached a repack for easier installing to nsis.

i also added some code to the include file for a future feature:
multiple sessions.

you'll get the idea by reading the new .nsh file :)


:D :up:

Nice one ;)


nsisXML (build 1.0.6)
More updates: includes function to remove attributes, a tidy function for xml files and a few debug functions that help you test your xpath syntaxes without saving the file :)

TODO:
1.- Tidy a inputed XML string (the last one) :p

@Commander: if you want to modify nsisxml.nsh send me the updated one by PM, thanks :)


Character Limit
Hi all,

I'm using ${nsisXML->SetElementText} to set a change a config file and set a connection string. However I get an "Runtime Error! abnormal program Termination" popup window and the instrcution is not executed.

The character string I am trying to set is greater than 64 characters long. If I try with a different (shorter) string, it works correctly.

Does anyone know anything about a character limit on the SetElementText method?

If it helps the simpleiset form of

Quote:


Thanks in advance for any help you can give.
George

Name "installer"

OutFile "C:\installer.exe"

!include "nsisXML.nsh"


Section "Installer"

${nsisXML->OpenXML} "C:\test.xml"

; If there are 63 x's the program will run, if there are 65 then an error will occur.

${nsisXML->SetElementText} "/a" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

${nsisXML->Release} "C:\test.xml"

SectionEnd

Please post both script & xml file to give it a look :)


HI Joel,

Here is a cut down version of what I am trying to do. Ziped up so there arent so many files to worry about.

Include & plugins contain the dll of nsisXML that I have been using. This is more for your reference than anything else.

Example.xml is the xml file I am trying to use. I am using this as the example as this file can't change in stucture or namespace (which has added other problems!).

Installer.exe is the installer as build on my machine.

Any more information you want let me know.

Cheers :)

George


I'll look it..this weekend, maybe the begin of the next one, I'll post an updated version dll one.


Multiple elemnts for SetElementText
I have a single Processed element, containing multiple Form elements, each with a single Path element.

I want to set all of the Path elements(across all the form elements) to the same value:
${nsisXML->SetElementText} "/Processed[0]/Form/Path[0]" "dsfgsdgsd"

However, this is only setting the Path element under the first form. Is there a way to iterate? Maybe using an iterator in the string? If that, then how would I know that I've gone past the last Form element? Would an error code be set that I can check each iteration of my loop, or can I use one of the other functions to test for the existance of the element before I try to set it?


Oh... anyone have a workaround for the issue with long text for SetElementText? :)


I know this thread has been dead quite some time, however I found the plug-in very useful - except for one thing: I was trying to set an ElementText with more than 64 characters, which failed.
So I downloaded the sources (thanks Joel for providing them) and did the quick change to now support 1024 characters. I've also created a simple project for Visual Studio 2008 to build this plug-in.

NOTE: I have not tested this code AT ALL! It does what I need and I haven't really changed much else. So most likely, no issues have been added by my change, but I don't know if this plug-in had any issues before that. Use at your own risk.

NOTE2: I don't know if I am allowed to upload msxml5.dll (the version I used to compile) - so I did not. If you need to compile the nsisXML.dll for yourself, you will have to find it or any other version > 2 and put it in the same folder as "main.cpp" and adapt the line "#import "msxml5.dll" " to the correct version number.

The ZIP file contains the sources, the project and the newly build nsisXML.dll (copy to your NSIS\plugins dir) and the (unchanged) nsisxml.nsh (copy to your NSIS\include dir)

Best

Martin

Please note that the attached plug-in depends on VS 2008 runtimes, msvcr90.dll may not be present on the customer comp (or you should handle the situation and install VS runtimes). Original plug-in from Joel created in VS 6 and depends on mcvcrt.dll, but this is acceptable. - Takhir


ripper17 (and release users - 20 downloads) - please note that plug-in depends on VS 2008 runtimes, msvcr90.dll may not present on the customer comp (or you should handle the situation and install VS runtimes). Original plug-in from Joel created in VS 6 and depends on mcvcrt.dll, but this is acceptable.


Added to post.

Stu


Archive: nsisXML: XML reader for Nsis


if I may suggest...

You can use this "other" nsisXML plug-in
which is compiled under VC6 for ANSI & Unicode NSIS and shouldn't have problem with long ElementText

It does however requires MSXML which is installed on every windows since Win98/IE4


Hello
I have an XML FIle wish contain a directory.Now I want to Use Nsis.But i don't know how can i pars the value of the attribute wish contain the directory from the XML File.
Also nsis should check if this directory exist.if not should Print a message, Like : "Le Dossier n'existe pas " ,Else,It terminate the execution of the rest of program
This is my XML FIle:
< v1>
<v2>
<v3 chemin= "c:\Dossier" taille=100>
<\v3>
<\v2>
<\v1>

in nsis,i want to get the value of Chemin.
Please,Can you write me what should i write in the nsi??


You already asked this question in your own thread. Please do not ask the same question twice. http://forums.winamp.com/showthread.php?t=332038