# XPath Template rules doesn't work

**URL:** <https://community.sonarsource.com/t/xpath-template-rules-doesnt-work/3665>\
**Category:** SonarQube Server / Community Build\
**Tags:** template\_rule, xml\
**Created:** [October 25, 2018, 9:17am UTC](https://community.sonarsource.com/t/xpath-template-rules-doesnt-work/3665 "2018-10-25T09:17:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TryingToCode](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@TryingToCode](https://community.sonarsource.com/u/TryingToCode)\
**Post date:** [October 25, 2018, 9:17am UTC](https://community.sonarsource.com/t/xpath-template-rules-doesnt-work/3665/1 "2018-10-25T09:17:50Z")

</div>

I want to analyze XML files in sonarqube and want to write custom rules with XPath.

If i use the default XML rules, it works and i get a response in form of an error. But if i write my own rules i get no respone.

I created a new Qualityprofile and activated my rules.

One of my rules looks like this:  
//CONTENT/CHAR\_DATA/TOKEN[@tokenValue=‘8.0.50727’]

With this rule i wanna check if the ProductVersion is correct. In the sslr-xml-toolkit-1.2 it works.  
Is there something in the settings what i’ve missed? Or is my rule wrong?

My syntax tree looks like this:

 ![xpath](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/e/eb4dc54a4b20c5fba6ba917d02526540534a3d1f.png)

My rule in sonarqube:

 ![testRule](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/b/bf32502780c3cd9502f7f540ebe6dc75aae7a4f3.png)

---

<div class="post-metadata">

**Author:** ![Lena](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lena/32/66719_2.png) [@Lena](https://community.sonarsource.com/u/Lena)\
**Post date:** [June 28, 2019, 9:50am UTC](https://community.sonarsource.com/t/xpath-template-rules-doesnt-work/3665/3 "2019-06-28T09:50:34Z")

</div>

Archiving as duplicate of

> [@Help with xpath for xml template rules](https://community.sonarsource.com/t/help-with-xpath-for-xml-template-rules/3750):
>
> Hi, i’m new to sonar and xpath and i have kind of the same problem. my XML broken down looks like this \<?xml version="1.0" encoding="utf-8"?\> \<Project\> \<ItemGroup\> \<ProjectReference\> \<Private\>False\</Private\> \</ProjectReference\> \</ItemGroup\> \</Project\> i want to write a custom rule which checks if is false or not and want to have an error if it is not false. I tried it w…

---

<div class="post-metadata">

**Author:** ![Lena](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lena/32/66719_2.png) [@Lena](https://community.sonarsource.com/u/Lena)\
**Post date:** [June 28, 2019, 9:50am UTC](https://community.sonarsource.com/t/xpath-template-rules-doesnt-work/3665/4 "2019-06-28T09:50:38Z")

</div>

Archived on June 28, 2019, 9:50am UTC


