# How to do a Query in JCR XPATH

**URL:** <https://community.bloomreach.com/t/how-to-do-a-query-in-jcr-xpath/367>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [September 5, 2018, 1:23pm UTC](https://community.bloomreach.com/t/how-to-do-a-query-in-jcr-xpath/367 "2018-09-05T13:23:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sola\_lee](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/sola_lee/32/81_2.png) [@sola\_lee](https://community.bloomreach.com/u/sola_lee)\
**Post date:** [September 5, 2018, 1:23pm UTC](https://community.bloomreach.com/t/how-to-do-a-query-in-jcr-xpath/367/1 "2018-09-05T13:23:27Z")

</div>

I have a simple data structure : Person (name,age,gender)

name, age , gender

1. sola, 48 male
2. carol 40 female
3. ishani 12 female

I need a simple to find where names = “sola” with a published status.

i did a simple xpath query and it was successful

//element(\*,xxxxxxxx:Person)/@jcr:path[@hippostd:state = ‘published’]

BUT when I try this

//element(\*,xxxxxxxx:Person)/@jcr:path[@hippostd:state = ‘published’ and @name=‘sola’]

I get blank because the actual value of name=sola is found inside that jcr:path.

How do I create a query or maybe a sub-query to search the value inside thet jcr:path

---

<div class="post-metadata">

**Author:** ![jasper.floor](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/jasper.floor/32/28_2.png) [@jasper.floor](https://community.bloomreach.com/u/jasper.floor)\
**Post date:** [September 5, 2018, 2:02pm UTC](https://community.bloomreach.com/t/how-to-do-a-query-in-jcr-xpath/367/2 "2018-09-05T14:02:29Z")

</div>

wouldn’t the following suffice?

//element(\*,xxxxxxxx:Person)[@hippostd:state = ‘published’ and @name=‘sola’]

---

<div class="post-metadata">

**Author:** ![sola\_lee](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/sola_lee/32/81_2.png) [@sola\_lee](https://community.bloomreach.com/u/sola_lee)\
**Post date:** [September 6, 2018, 4:35am UTC](https://community.bloomreach.com/t/how-to-do-a-query-in-jcr-xpath/367/3 "2018-09-06T04:35:37Z")

</div>

Thanks Jasper.floor

I tried that too, it did not work.

Maybe I need to clarify, sorry for my weak explanation yesterday.

* * *

In the [http://localhost:8080/cms/respository](http://localhost:8080/cms/respository), if I choose XPath and paste the following query

//element(\*,xxxxxxxx:Person)/@jcr:path[@hippostd:state = ‘published’]

I will get the following links:

/content/documents/xxxxxxxx/Person/person1/person1[3]  
/content/documents/xxxxxxxx/Person/person2/person2[3]  
/content/documents/xxxxxxxx/Person/person3/person3[3]

And the table with columns(#,jcr:path,jcr:score)

1 /content/documents/xxxxxxxx/Person/person1/person1[3] 12947  
2 /content/documents/xxxxxxxx/Person/person2/person2[3] 12947  
3 /content/documents/xxxxxxxx/Person/person3/person3[3] 12947

**Only if I click on the links (I assume to be the subquery) for example**

/content/documents/xxxxxxxx/Person/person1/person1[3]

Then I will be able to see the list of values

Access node : /[root/content/document/xxxxxxxx/person/person1

- [name=“xxxxxxxx:name”] = Sola
- [name=“xxxxxxxx:age”] = 48
- [name=“xxxxxxxx:gender”] = male

* * *

Is there a query I can call like you example:

//element(\*,xxxxxxxx:Person)[@hippostd:state = ‘published’ and @name=‘sola’]

---

<div class="post-metadata">

**Author:** ![sola\_lee](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/sola_lee/32/81_2.png) [@sola\_lee](https://community.bloomreach.com/u/sola_lee)\
**Post date:** [September 6, 2018, 4:44am UTC](https://community.bloomreach.com/t/how-to-do-a-query-in-jcr-xpath/367/4 "2018-09-06T04:44:26Z")

</div>

Yes jasper you are right with a small tweak, the answer is

//element(\*,xxxxxxxx:Person)[@hippostd:state = ‘published’ and @xxxxxxxx:name=‘sola’]

Thank you

---

<div class="post-metadata">

**Author:** ![jasper.floor](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/jasper.floor/32/28_2.png) [@jasper.floor](https://community.bloomreach.com/u/jasper.floor)\
**Post date:** [September 6, 2018, 7:39am UTC](https://community.bloomreach.com/t/how-to-do-a-query-in-jcr-xpath/367/5 "2018-09-06T07:39:05Z")

</div>

Great, thanks for letting us know you reached a solution!
