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.

TEST1/WORKSPACE/hst:pages.

thanks & regards
Ganesh

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.

HTH
Jeroen

Hello Jeroen.hoffman,

thank you, it works for me.

regards
Ganesh

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
ganesh

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();
dkNode.addNode(actualNode.getPath())

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: {} {http://www.hippoecm.org/hst/nt/2.1}hst {http://www.hippoecm.org/hst/nt/2.1}configurations {}cmsdigitalcontent {http://www.hippoecm.org/hst/nt/2.1}workspace {http://www.hippoecm.org/hst/nt/2.1}pages {}test-page-1-Landing

could you please help me.

thanks & regards
Ganesh

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

edit:
see https://code.onehippo.org/cms-community/hippo-repository/blob/hippo-repository-13.4.1/api/src/main/java/org/hippoecm/repository/util/JcrUtils.java

Hello Machak,

thanks a lot for your time and response.

it’s works fine now.