# Xpath expression for blocking missing \<scope\> node

**URL:** <https://community.sonarsource.com/t/xpath-expression-for-blocking-missing-scope-node/67900>\
**Category:** SonarQube Server / Community Build\
**Tags:** xml, sonarqube\
**Created:** [July 12, 2022, 10:15am UTC](https://community.sonarsource.com/t/xpath-expression-for-blocking-missing-scope-node/67900 "2022-07-12T10:15:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramarro123](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ramarro123/32/35111_2.png) [@ramarro123](https://community.sonarsource.com/u/ramarro123)\
**Post date:** [July 12, 2022, 10:15am UTC](https://community.sonarsource.com/t/xpath-expression-for-blocking-missing-scope-node/67900/1 "2022-07-12T10:15:49Z")

</div>

- 9.5 community
- block an xml (a pom) that doesn’t contain a certain tag
- via xpath template

hello,

i would like to create an xml template to match this situation

```
    <dependency>
        <groupId>blabla</groupId>
        <artifactId>fabrickcore-spring-boot-starter-test</artifactId>
    </dependency>

```

the “factor” it’s the missing of tag

on this website i try

> **[Free Online XPath Tester / Evaluator - FreeFormatter.com](https://www.freeformatter.com/xpath-tester.html#before-output)**
>
> This free online XPath tester lets you test your expressions/queries against an XML file

the following xpath expression

```auto
//dependency/artifactId/text()[. = 'fabrickcore-spring-boot-starter-test']/../..[not(scope)]

```

and this match (correct)

> ```
> <dependency>
> <groupId>blabla</groupId>
> <artifactId>fabrickcore-spring-boot-starter-test</artifactId>
> </dependency>
> 
> ```

and don’t match (correct)

> ```
> <dependency>
> <groupId>blabla</groupId>
> <artifactId>fabrickcore-spring-boot-starter-test</artifactId>
> <scope>blabla</scope>
> </dependency>
> 
> ```

so from the tester point of view my xpath expression it’s working.

on sonar i am not able to make it work, and i can’t get any debug information about that.

i think (but i am not sure) it’s the last part that break ie: [not(scope)] because if i do a rule with

```auto
//dependency/artifactId/text()[. = 'fabrickcore-spring-boot-starter-test']/../..

```

the rule work and match the element (that’s of course not the scenario i need, but i did try to break out a bit the expression)

can someone advice on that?

thanks for the support!

ps: not sure why but the code display 3 dots, while i use 2 dots in xpath 😃

---

<div class="post-metadata">

**Author:** ![chrislain](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/chrislain/32/33859_2.png) [@chrislain](https://community.sonarsource.com/u/chrislain)\
**Post date:** [March 2, 2023, 4:44pm UTC](https://community.sonarsource.com/t/xpath-expression-for-blocking-missing-scope-node/67900/4 "2023-03-02T16:44:23Z")

</div>

Hello @ramarro123,

Could you let me know whether you are using xpath 1 or 2 please?

Best.
