Yes.  It's not very complicated.  The specific steps in the innermost custom 
action (there is another custom action that drives this one from a table) are:

1) load path to XML file from property;
2) load XPATH from property;
3) create an XmlDocument instance
4) use the TrySafeLoad method to see if I can load the XML file, exit if I can't
5) get an XmlNode using SelectSingleNode on the XPATH previously loaded;
6) if the XmlNode is null, store a default value;
7) else process for attribute, element, or inner text and load the property;
8) exit

The code following this flow has been used in production for over two years.

--
John Merryweather Cooper
Senior Software Engineer | Integration Development Group | Continuing 
Development
Jack Henry & Associates, Inc.® | Lenexa, KS  66214 | Ext:  431050 
|jocoo...@jackhenry.com



-----Original Message-----
From: Davis, Jeff [mailto:jda...@nanometrics.com] 
Sent: Friday, March 6, 2015 12:02 PM
To: General discussion about the WiX toolset.
Subject: [WiX-users] Custom Action to Read XML value

It seems like the answer to every question about reading XML value using Wix is 
to write a custom action.  I have found a couple of solutions that I have tried 
with no success.   Does someone have a working XML Search custom action that 
you pass a XML filename and a XPath value and it will populate a Property value 
with its results.   I don't need to add an extension with lots of other actions 
or an action that a lot more than what I need.  Although if you're using 
something that works I'd take it.

I need it to be able to evaluate complex XPath expressions with valid XST 
functions like substring-before() so I can parse Values.

Has someone got something that works for them that they don't mind sharing so I 
don't have to write my own?  (which is not my strong point)



This solution is what I am looking for but I can't get it to work for me.

http://www.codeproject.com/Articles/865604/Writing-a-Wix-Extension-to-Read-XML-Files

When I try to build the project I get several errors.

Error 1 The command "copy 
".\Wix.XmlSearch_src\XmlSearch.WixLib\bin\Debug\XmlSearch.wixlib" 
".\Wix.XmlSearch_src\Resources" /y" exited with code 1. Wix.XmlSearch

If I add this to the Wix.Test.Setup Product.wxs

<xmlsearch:XmlSearch Id="Test1" File="$(var.ProjectDir)Test.xml" 
XPath="/Testdata/testnode/@Value"/>

I get this error

Error 1 The Property element contains an unhandled extension element 
'xmlsearch:XmlSearch'. Please ensure that the extension for elements in the 
'http://schemas.rottedfrog.co.uk/wix/XmlSearch' namespace has been provided.

If I try to add the binary to a project I get this error

A reference to C:\Program Files (x86)\WiX Toolset v3.9\bin\\Wix.WmlSearch.dll 
could not be added. Please make sure tha tthe file is accessible, and that it 
is a valid Wix reference.


I have tried this one which works pretty well

https://bitbucket.org/nirbar1/panelswwixextension

But there is a bug in the XPath expression evaluation that won't allow 
functions like substring-before()  etc to be used.



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored 
by Intel and developed in partnership with Slashdot Media, is your hub for all 
things parallel software development, from weekly thought leadership blogs to 
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users
NOTICE: This electronic mail message and any files transmitted with it are 
intended
exclusively for the individual or entity to which it is addressed. The message, 
together with any attachment, may contain confidential and/or privileged 
information.
Any unauthorized review, use, printing, saving, copying, disclosure or 
distribution 
is strictly prohibited. If you have received this message in error, please 
immediately advise the sender by reply email and delete all copies.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to