1

I have a installer through which i need to update an XML file. I have done these kinds of stuff many time to update application config files. But this XML file is little different and i am facing an issue to find the node. I don't know why it is not working. I have below XML:

<?xml version="1.0" encoding="utf-8"?>
<Siemens.Automation.Diagnostics 

 xmlns="http://www.siemens.com/Automation/2004/09/Diagnostics/ReportConfiguration">
       <Report IncludeConfigFile="true" IncludeHtml="true" DisplayName="Red White Application" TargetVersion="1.0.0">
        <MergePlugIns>
          <MergePlugIn Path="Siemens.Automation.Diagnostics.PlugIn.dll" Type="Siemens.Automation.Diagnostics.PlugIn.ConfigurationMerger" />
        </MergePlugIns>

      </Report>
    </Siemens.Automation.Diagnostics>

I want to update Type of MergePlugin value but i am facing issue. Below is what i am doing:

<util:XmlFile Id="UpdateProductName" Action="setValue" File="[ERRORREPORT]$(var.ErrorReportAdrFile)"
                      ElementPath="/Siemens.Automation.Diagnostics[\[]@xmlns='http://www.siemens.com/Automation/2004/09/Diagnostics/ReportConfiguration'[\]]/Report[\[]@DisplayName='Red White Application'[\]]/MergePlugIns/MergePlugIn[\[]@Path='Siemens.Automation.Diagnostics.PlugIn.dll'[\]]/@Type"
                      SelectionLanguage="XPath" Permanent="yes" Value="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SIPLACE\$(var.ProductName)"/>

But it gives an error that unable to find node. What i am missing?

zett42
  • 25,437
  • 3
  • 35
  • 72
Umer Waheed
  • 4,044
  • 7
  • 41
  • 62

1 Answers1

1

Some XPath libraries have trouble when element names contain period (".").

Given the workaround from this answer, you have to replace the first part of your XPath:

/Siemens.Automation.Diagnostics

by

/*[name(.)='Siemens.Automation.Diagnostics']

and with proper escaping for MSI formatted field the answer finally is:

/*[\[]name(.)='Siemens.Automation.Diagnostics'[\]]

It succeeds when pasted in this online XPath tester.

zett42
  • 25,437
  • 3
  • 35
  • 72