[opencms-dev] How to loop inside an XmlContent using jsp?
Joe Lam
joe.lam at moni-media.net
Sun Aug 27 13:42:17 CEST 2006
I am trying to load xml content via jsp rather than via
<cms:contentload/> tag.
I guess using jsp to read xml content should make things easier.
my codes are like these:
CmsResource cmsr = cmso.readResource(path, CmsResourceFilter.ALL);
CmsXmlContent content = CmsXmlContentFactory.unmarshal(cmso, cmsr,
request);
String title = content.getStringValue(cmso, "Title", myLocale);
I'm OK to read the top level element but I got problem to loop inside
the nested type.
If I want the *Style *element inside the nested type *SubArticle*, I
could only do it like this.
int subArticleCount=content.getIndexCount("SubArticle",myLocale);
for(int i=0;i<subArticleCount;i++){
String Style = content.getStringValue(cmso,
"SubArticle["+(i+1)+"]/Style", myLocale);
}
This is obvious a bad way to get inner value like this. Anyone wants how
to "step into" the nested type, such that I could do something like
currentSubArticle.getStringValue(cmso, "Style", myLocale);
Thank you very much
Cheers
Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060827/e075db0e/attachment.htm>
More information about the opencms-dev
mailing list