How to use a template and variable name to count some values

May 9, 2013 at 11:42:02
Specs: Windows 7
I use a template as

<xsl:template name="myTemplate">

and I need to count the amount of level nodes whose values are "ON" and "OFF".

The final report that I want to have: "This file contains three "ON" values and two "OFF" values".

Look at a part of my xml file.

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml:stylesheet type='text/xsl' href='view.xsl'?>
<DOC>
<show>VIEW<show/>
<Entry>
<light>ae</light>
<level>ON</level>
</Entry>
<Entry>
<light>by</light>
<level>OFF</level>
</Entry>
<Entry>
<light>ac</light>
<level>OFF</level>
</Entry>
<Entry>
<light>pc</light>
<level>ON</level>
</Entry>
<Entry>
<light>tc</light>
<level>ON</level>
</Entry>

Thank for your help


See More: How to use a template and variable name to count some values

Report •


#1
May 17, 2013 at 07:14:12
Don't know why nobody else did this, it's really simple:
@echo off & setlocal enabledelayedexpansion
set filetosearchin=example.xml
for /f "delims=" %%a in ('type %filetosearchin% ^| find /C /I "<level>off</level>"') do set off=%%a
for /f "delims=" %%a in ('type %filetosearchin% ^| find /C /I "<level>on</level>"') do set on=%%a
echo.File:"%filetosearchin%" contains "%off%" off values and "%on%" on values.
pause > nul
exit /b


Report •
Related Solutions


Ask Question