Question

I would like to extract the version number from this code:

<?xml version="1.0" encoding="UTF-8"?>
<Include>
  <?define ProductVersion = "1.0.0.0" ?>
</Include>

I want the output to be: 1.0.0.0, is it possible to do this?

Était-ce utile?

La solution

If you are using Visual Studio to create the WIX based installer then you can define your ProductVersion variable in the .wixproj file.

  <Target Name="BeforeBuild">
    <PropertyGroup>
      <DefineConstants>ProductVersion=1.0</DefineConstants>
      ...
    </PropertyGroup>
  </Target>

This would be accessible from .wxs file by $(var.ProductVersion). Now you can use XPath to read the value of DefineConstants from your .wixproj file. This will get you ProductVersion = "1.0.0.0"

Autres conseils

You can access the processing instruction content using the processing-instruction() node filter. There is no semantic defined within a processing instruction, so you cannot directly query for the "attribute value".

You can use this XPath (1.0) query to fetch the value using string processing:

substring-before(substring-after(/Include/processing-instruction(), '"'), '"')
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top