NsisXML plug-in (by Wizou): Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m ("occured" -> "occurred".) |
(→Description: Clarify nsisXML::select source) |
||
(11 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{PageAuthor|Wizou}} | {{PageAuthor|Wizou}} | ||
Note: The name of this plug-in conflicts with [[User:Joel|Joel]]'s [[NsisXML- A XML parser for NSIS|nsisXML]]. | |||
== Links == | == Links == | ||
[http:// | [http://wiz0u.free.fr/prog/nsisXML/ nsisXML plug-in homepage] | ||
== Description == | == Description == | ||
Line 26: | Line 26: | ||
(if XML document $0 is not empty, all content will be discarded) | (if XML document $0 is not empty, all content will be discarded) | ||
sets $0 to 0 if an error occurred | sets $0 to 0 if an error occurred | ||
nsisXML::loadAndValidate <filename> | |||
same as load but performs validation on the XML if a schema is present, and | |||
resolves external definitions (may try to establish an Internet connection) | |||
nsisXML::save <filename> | nsisXML::save <filename> | ||
Line 39: | Line 43: | ||
nsisXML::appendChild | nsisXML::appendChild | ||
appends node $2 as a child of node $1 | appends node $2 as a child of node $1 | ||
nsisXML::insertBefore | |||
insert node $2 as a child of node $1, to the left of node $3 | |||
($3 must be a reference to a child node of $1) | |||
nsisXML::setAttribute <attribute name> <value> | nsisXML::setAttribute <attribute name> <value> | ||
Line 54: | Line 62: | ||
nsisXML::select <XPath expression> | nsisXML::select <XPath expression> | ||
find the first node matching the given XPath expression and return its | find the first node matching the given XPath expression on document in $0 and return its | ||
reference in $1 and $2 | reference in $1 and $2 | ||
if not found, reference will be 0 | if not found, reference will be 0 | ||
Line 63: | Line 71: | ||
nsisXML::removeChild | nsisXML::removeChild | ||
removes node $2 from the childs list of node $1 | removes node $2 from the childs list of node $1 | ||
nsisXML::release <node reference> | |||
release immediately the memory associated with given node (typically $2, $1 or $0) | |||
for every nsisXML function that returns a node reference, you may want to release its memory after you're done working with the reference. | |||
however, please note that in any case, all memory used by MSXML will be released when your installer terminates. | |||
(so usually this is not a big concern) | |||
</pre> | </pre> | ||
== History == | |||
2010-04-02: Added "release" to prevent memory leaks. | |||
Automatic use of most recent MSXML available. | |||
DLL is no longer unloaded after each call (you don't need /NOUNLOAD anymore) | |||
2006-03-22: Added "insertBefore" | |||
2006-03-13: Modified "load". Added "loadAndValidation" | |||
[[Category:Plugins]] | [[Category:Plugins]] |
Latest revision as of 22:42, 20 October 2017
Author: Wizou (talk, contrib) |
Note: The name of this plug-in conflicts with Joel's nsisXML.
Links
Description
nsisXML -- Small NSIS plugin to manipulate XML data through MSXML written by Olivier Marcoux
The following is taken from the readme file in the downloadable zip file:
You can typically use it to: - create, read, modify, write XML files - create, remove, search XML nodes - set/get nodes content or attributes Usage ----- nsisXML::create creates an empty XML document in memory and returns its reference in $0 and $1 nsisXML::load <filename> load given XML file into document $0 REQUIRES that an XML document be already created in $0 (if XML document $0 is not empty, all content will be discarded) sets $0 to 0 if an error occurred nsisXML::loadAndValidate <filename> same as load but performs validation on the XML if a schema is present, and resolves external definitions (may try to establish an Internet connection) nsisXML::save <filename> saves current document $0 to given file nsisXML::createProcessingInstruction <target> <data> creates a new 'processing instruction' node and return its reference in $2 nsisXML::createElement <tag name> creates a new element node with given tag name (initially empty) and return its reference in $2 nsisXML::appendChild appends node $2 as a child of node $1 nsisXML::insertBefore insert node $2 as a child of node $1, to the left of node $3 ($3 must be a reference to a child node of $1) nsisXML::setAttribute <attribute name> <value> sets the given attribute with the given value on node $2 nsisXML::getAttribute <attribute name> returns in $3 the value for the given attribute name of node $2 if attribute is not found, returns an empty string nsisXML::setText <content text> sets the text content of the node $2 (<>the text between the tags</>) nsisXML::getText returns in $3 the text content for node $2 nsisXML::select <XPath expression> find the first node matching the given XPath expression on document in $0 and return its reference in $1 and $2 if not found, reference will be 0 nsisXML::parentNode returns in $1 the reference on the parent node of node $2 nsisXML::removeChild removes node $2 from the childs list of node $1 nsisXML::release <node reference> release immediately the memory associated with given node (typically $2, $1 or $0) for every nsisXML function that returns a node reference, you may want to release its memory after you're done working with the reference. however, please note that in any case, all memory used by MSXML will be released when your installer terminates. (so usually this is not a big concern)
History
2010-04-02: Added "release" to prevent memory leaks. Automatic use of most recent MSXML available. DLL is no longer unloaded after each call (you don't need /NOUNLOAD anymore)
2006-03-22: Added "insertBefore"
2006-03-13: Modified "load". Added "loadAndValidation"