[opencms-dev] Writing multiple nodes of the same name using CmsXmlContent

Paul-Inge Flakstad flakstad at npolar.no
Thu Oct 6 11:00:13 CEST 2011


Hi Yves,

Maybe something like this (I haven’t tested this):

xmlContent.addValue(cmsObject, "Tag", new Locale("en"), 0). setStringValue(cmso, "iPod");
xmlContent.addValue(cmsObject, "Tag", new Locale("en"), 1).setStringValue(cmso, "iPhone");
xmlContent.addValue(cmsObject, "Tag", new Locale("en"), 2).setStringValue(cmso, "iPad");

HTH

Cheers,
Paul

From: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Yves Glodt
Sent: 6. oktober 2011 10:36
To: The OpenCms mailing list
Subject: [opencms-dev] Writing multiple nodes of the same name using CmsXmlContent

Hello,

I have a problem writing mulsiple nodes of the same name using the OpenCms Api.

This is what I want to achieve:

<XmlContentDocSimpleTypes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="opencms://sites/knowledgebase/core/document.xsd">
  <XmlContentDocSimpleType language="en">
    <Title><![CDATA[My Title]]></Title>
    <Content name="Content0">
      <links/>
      <content><![CDATA[<p>lorem ipsum ...</p>]]></content>
    </Content>
    <Tag><![CDATA[linux]]></Tag>
    <Tag><![CDATA[web]]></Tag>
    <Tag><![CDATA[java]]></Tag>
    <Author><![CDATA[me]]></Author>
    <ChangedDate>1317474420000</ChangedDate>
  </XmlContentDocSimpleType>
</XmlContentDocSimpleTypes>


And this is how I proceed:

CmsXmlContent xmlContent = null;

I_CmsXmlContentValue xmlContentValue = null;

xmlContentValue = xmlContent.getValue("Title", new Locale("en"));
xmlContentValue.setStringValue(cmso, "My Title");

...

xmlContentValue = xmlContent.getValue("Tag", new Locale("en"));
xmlContentValue.setStringValue(cmso, "linux");


If I repeat the last 2 calls, of course the "Tag" node is replaced.
How can I add another "Tag" ? :-)


Best regards,
Yves
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20111006/eaa16aca/attachment.htm>


More information about the opencms-dev mailing list