nsXML - an MSXML NSIS XML plugin
Been working on an XML writing plugin recently and have come up with the following API...
initCOM
init
startElem
endElem
startDocument
endDocument
insertElemVal
elemVal
write
uninitCOM
I'm using MSXML and SAX for the writer so this should allow for some pretty strict error checking when required plus it's probably the XML parser I know best. Note that it only does writing right now, I'm playing around with some stuff for how parsing might work. The API is pretty much a wrapper for an MSXML SAX writer instance so if you are familiar with that then you should have no troubles. I am still open for suggestions/request so if you have some please let me know this thing is far from done. You need MSXML 3 so make sure you have that. I'm not sure if you need a specific revision of the MSXML3.dll I'll see if I can find out.
init - Intializes a bunch of MSXML parser instance
stuff
startDocument - Starts a document in memory
endDocument - Ends a document in memory
startElem - Start an element in the document, it'll insert something like "<Start>" but not the cooresponding "</Start>" which of course is what endElem is for
endElem - As I mentioned inserts the end element tag "</Start>" for example
elemVal - Inserts a value for the current element. Should be preceeded by a call to startElem and proceeded by a call to endElem
insertElemVal - Combines calls to startElement, endElement and characters to write an element into the XML document. In the example above
nsXML::insertElemVal "Hello" "123"
would insert <Hello>123</Hello> into the XML document
write - Writes the constrcuted XML doc out to the file you specify
initCOM & uninitCOM - Are only necessary if you don't use COM elsewhere in other plugins. Call CoInitialize and CoUninitialize respectively.
And here's an example script snippet which you should just be able to try out
nsXML::initCOM
nsXML::init
nsXML::startDocument
nsXML::insertElemVal "Hello" "123"
nsXML::insertElemVal "Hel2lo" "1233333"
nsXML::endDocument
nsXML::write "c:\temp.xml"
nsXML::uninitCOM
The plugins attached for you to try out although quite buggy at this point. I'm getting a crash on shutdown of any installers I make with the plugin. I'm looking into it.
Other features I plan to add...
-Search and replace on a specific element or value
-Unicode support (not sure if this is possible with language tables or not but it would be really cool if you could do it)
-support for DOM parser/writer