Could you please let me know xPath to get pages from specific channel

Hello All,

I am trying to get pages from specific channel.
we have multiple ex: TEST1, TEST2 channels

i would like to get the pages from TEST1 channel workspace/hst:pages.


thanks & regards

I think you’re looking for something like
hst:hst/hst:configurations/TEST1/hst:pages/element(*, hst:component)
The top level node may have an implementation specific name for you.


Hello Jeroen.hoffman,

thank you, it works for me.


Hello Jeroen.hoffman,

is it possible to copy all those pages from one channel to another channel using groovy script ?

i gone to admin/Updater Editor and trying to write groovy script.

thanks & regards

Hi Jeroen.hoffman,

I am able to write groovy script to get all channels, now am trying to copy pages from
one channel to another.

i tried with below snippet.

Query query = queryManager.createQuery(desktopPath,Query.XPATH);
Node dkNode = query.execute().getNodes().nextNode();

which is giving errors.

ERROR 2020-02-19 17:39:22 Updating /hst:hst/hst:configurations/cmsdigitalcontent failed - java.lang.IllegalArgumentException: relPath is not a relative path: {} {}hst {}configurations {}cmsdigitalcontent {}workspace {}pages {}test-page-1-Landing

could you please help me.

thanks & regards

node.getPath() returns you absolute path, so, error is quite clear no? You need to use relative paths, so, in your case, you should use node.getName().
But, easier is to use copy methods from following class: org.hippoecm.repository.util.JcrUtils


Hello Machak,

thanks a lot for your time and response.

it’s works fine now.