[opencms-dev] Question about OpenCms Programming
Anatol
opencms at recordcaster.de
Thu Nov 17 20:34:08 CET 2005
Hi Christof!
Hey thanks!! that looks very good!! I'll try it :-))
Anatol
Christof Dallermassl schrieb:
>Hi!
>
>
>
>>I've a question about the OpenCms Programming concerning creating and
>>manipulating a XmlContentDocument. Meenwhile I can _create_ an empty
>>XmlContentDocument:
>>CmsObject.createResource(<path/filename>,<ContentID>) works fine ;-)
>>
>>But now I 've only the raw structure! How can I change the "values" with
>>some Java-Functions? for example: How can I change from
>>
>>
>
>// create a new content:
>CmsObject cms; // get one or create one with username/password
>CmsXmlContentDefinition contentDef = CmsXmlContentDefinition.unmarshal(cms, pathToXsdFile);
>CmsXmlContent content = CmsXmlContentFactory.createDocument(cms, locale, "UTF-8", contentDef);
>
>// or read an existing one:
>CmsResource resource = cms.readResource(pathToResource);
>CmsFile file = CmsFile.upgrade(resource, cms);
>
>// change content:
>content = CmsXmlContentFactory.unmarshal(cms, file);
>content.getValue("name", locale).setStringValue(cms, "hans");
>
>// write the content, or otherwise the changes are lost!:
>file.setContents(content.marshal());
>cms.writeFile(file);
>
>
>regards
>Christof
>
>
>_______________________________________________
>This mail is send to you from the opencms-dev mailing list
>To change your list options, or to unsubscribe from the list, please visit
>http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>
>
>
More information about the opencms-dev
mailing list