[opencms-dev] how to update xml values within a CmsFile

Nacho Fernandez snatcho at gmail.com
Thu May 29 08:14:44 CEST 2008


Hi frankg,

You can try something like this:

            String completePathToDocument = cms.getSitePath(
xmlDocument.getFile() );
            xmlDocument.getValue( string_with_the_field_name_to_modify,
locale ).setStringValue( cms, new_value_to_set );
            cms.lockResource( completePathToDocument, CmsLock.TEMPORARY );
            xmlDocument.getFile().setContents( xmlDocument.marshal() );
            cms.writeFile( xmlDocument.getFile() );

That should have your xml file field updated. Hope it helps! If it works
fine for you, I recommend you to parametrize it and make it an utility
function for your code to call. Greetings,

Nacho Fernandez.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20080529/4e09fd3b/attachment.htm>


More information about the opencms-dev mailing list