0

I'm trying to figure out how to modify an XML file with NSIS. So I'm trying to learn how to use the XML plugin. The examples on the forum page often use the format ${plugin::command} like:

${xml::LoadFile}

The documentation gives no indication that you need the dollar sign and curly braces. As I understand it, just plugin::command will do. So I've been trying to figure out what that syntax means.

The documentation says a $ is for variables and the {} are for code blocks, but I can't find anything about what it means when they're used together. My Internet searches have revealed that it's used for something called template literals in JavaScript. But what does it mean in NSIS?

EDIT: I should mention that the NSIS documentation does show examples of this syntax, especially in the Predefines section, but it still doesn't explain what the syntax means in general.

EDIT: Okay, now I see that the syntax is for the compiler to replace things using !define and !macro. But... what about this specific case? Is it valid to use colons in such a symbol? Why are some people writing ${xml::LoadFile}and some people just writing xml::LoadFile?

Kyle Delaney
  • 11,616
  • 6
  • 39
  • 66

1 Answers1

2

It's a !define. There is a header file for this plugin that defines it. The plugin probably needs to do more than one thing, so they wrapped a few lines together with a define that inserts a macro. Either that or it has some default parameters for the plugin call. Either way, it's trying to save you some typing with this syntax.

kichik
  • 33,220
  • 7
  • 94
  • 114
  • Thank you, now I've found an explanation for that syntax in the conditional compilation section. But... the XML plugin has no header file. Also, is `plugin::command` even a valid symbol for `!define`? Surely they'd use a symbol without colons, right? – Kyle Delaney Jan 17 '18 at 17:41
  • Make sure you're looking into the right XML plug-in. There are a few of them. If you already extracted the ZIP file, look for the header in the `Include` folder. As for the syntax, yes, it's valid. – kichik Jan 17 '18 at 17:43
  • Oh, I was looking at version 1.6 instead of 1.7. – Kyle Delaney Jan 17 '18 at 17:51
  • Since you say you're aware of multiple XML plugins for NSIS, do you happen to know of one that allows me to navigate to a node based on an attribute value? I've examined the xml.dll source code and it doesn't use XPath or anything. – Kyle Delaney Jan 17 '18 at 21:09