below is my structure enter image description here
as of now I am using below code to get the value and set it to an element to write it into a xml document:
Iterator childPages = page.listChildren();
while (childPages.hasNext()) {
Page childPage = childPages.next();
Iterator<Page> grandChildPages = childPage.listChildren();
while (grandChildPages.hasNext()) {
Page grandChildPage = grandChildPages.next();
Element grandChildItem = document.createElement("item");
channel.appendChild(grandChildItem);
String textNodePath = grandChildPage.getPath() + RssConstants.CONTENT_SUBTITLE;
Resource textNodeResource = resourceResolver.getResource(textNodePath);
if (textNodeResource != null) {
ValueMap textNodeValueMap = textNodeResource.getValueMap();
String textNodeValue = textNodeValueMap.get("text", "");
Element subTitle = document.createElement("subTitle");
subTitle.appendChild(document.createTextNode(textNodeValue));
grandChildItem.appendChild(subTitle);
}
String grandChildNodePath = grandChildPage.getPath() + "/" + JcrConstants.JCR_CONTENT;
Resource resource = resourceResolver.getResource(grandChildNodePath);
ValueMap valueMap = resource.getValueMap();
String grandChildTitle = valueMap.get("jcr:title", "");
log.info("Grandchild Title: " + grandChildTitle);
}
}
I am directly passing the path in CONTENT_SUBTITLE which is not correct the container id may change while authoring. expecting to get this dynamically