- NSIS Discussion
- Xml
Archive: Xml
guyguy333
26th June 2009 20:29 UTC
Xml
Hello
I'm new and i'm french and so sorry for my bad english
I would like to use XML in NSIS
So I've choice between the plugin by Wizou and by Joel
What is the best ?
But the most important it's that I don't arrive to make that I want
I would like to open an XML who have already data without delete it when I create an element for example... and I don't arrive to make it because the plugin delete all data in XML
Thanks
pengyou
27th June 2009 10:51 UTC
There is another XML plugin (by Instructor) you can try: http://nsis.sourceforge.net/XML_plug-in
I found it useful.
guyguy333
27th June 2009 17:12 UTC
Originally posted by pengyou
There is another XML plugin (by Instructor) you can try: http://nsis.sourceforge.net/XML_plug-in
I found it useful.
Thanks you, it's true, It is more complete and it works !
guyguy333
27th June 2009 22:16 UTC
Sorry, but with this plugin, i don't arrive to simple add a Node in an empty XML
${xml::LoadFile} "$INSTDIR\addons.xml" $0
${xml::CreateNode} '<addon nom="Test">test</addon>'
${xml::SaveFile} "$INSTDIR\addons.xml" $0
${xml::Unload}
demiller9
27th June 2009 23:25 UTC
I think you left out the file var in the createnode command:
${xml::CreateNode} '<addon nom="Test">test</addon>' $0
(I haven't tested this, just read the docs.)
pengyou
28th June 2009 00:04 UTC
${xml::CreateNode} only creates the node in memory and returns its handle. You need to use this handle value with another function to get this new node into the file:
${xml::InsertAfterNode}
${xml::InsertBeforeNode}
${xml::InsertEndChild}
${xml::ReplaceNode}
For example:
${xml::CreateNode} '<addon nom="Test">test</addon>' $1
${xml::ReplaceNode} "$1" $0
guyguy333
28th June 2009 08:56 UTC
Originally posted by pengyou
${xml::CreateNode} only creates the node in memory and returns its handle. You need to use this handle value with another function to get this new node into the file:
${xml::InsertAfterNode}
${xml::InsertBeforeNode}
${xml::InsertEndChild}
${xml::ReplaceNode}
For example:
${xml::CreateNode} '<addon nom="Test">test</addon>' $1
${xml::ReplaceNode} "$1" $0
Ok thanks but if my XML doesn't have Node and Child in the XML File,
${xml::InsertAfterNode}
${xml::InsertBeforeNode}
${xml::InsertEndChild}
${xml::ReplaceNode}
can not introduce my Node, no ?
So how can I do?
Thanks for your help
pengyou
28th June 2009 14:19 UTC
my XML doesn't have Node and Child in the XML File
Are you trying to use the XML plugin to
create an XML file?
The author of the XML plugin suggests using FileWrite commands to create an XML file. You only need to create a small XML file then you can use the XML plugin to add things to it or change things in it. Here is a code fragment that creates a small XML file and then modifies it.
FileOpen $R9 "addons.xml" w
FileWrite $R9 "<config><local>Dummy</local></config>"
FileClose $R9
${xml::LoadFile} "addons.xml" $0
${xml::RootElement} $1 $0
${xml::CreateNode} '<addon nom="Test">test</addon>' $1
${xml::InsertEndChild} "$1" $0
${xml::SaveFile} "addons.xml" $0
${xml::Unload}
This creates a file called addons.xml then modifies it to end up like this:
<config>
<local>Dummy</local>
<addon nom="Test">test</addon>
</config>
guyguy333
28th June 2009 22:13 UTC
Originally posted by pengyou
Are you trying to use the XML plugin to create an XML file?
The author of the XML plugin suggests using FileWrite commands to create an XML file. You only need to create a small XML file then you can use the XML plugin to add things to it or change things in it. Here is a code fragment that creates a small XML file and then modifies it.
FileOpen $R9 "addons.xml" w
FileWrite $R9 "<config><local>Dummy</local></config>"
FileClose $R9
${xml::LoadFile} "addons.xml" $0
${xml::RootElement} $1 $0
${xml::CreateNode} '<addon nom="Test">test</addon>' $1
${xml::InsertEndChild} "$1" $0
${xml::SaveFile} "addons.xml" $0
${xml::Unload}
This creates a file called addons.xml then modifies it to end up like this:
<config>
<local>Dummy</local>
<addon nom="Test">test</addon>
</config>
Ok thanks you, i understood
I would like to know if it's possible to make a search into XML
For example, before to add my addon in the XML file, I would like to be sure that it is not already into.
I don't know if it's possible
pengyou
28th June 2009 23:26 UTC
I would like to know if it's possible to make a search into XML
Yes, you can search it. There are some examples in the XMLTest.nsi script supplied with the plugin and the documentation gives details of the various ways to search/goto something in the XML file.
There are a couple of pages discussing the XML plugin here:
http://forums.winamp.com/showthread....hreadid=227162