[opencms-dev] Remove nodes from a structured XML file
Brabenetz, Harald
harald.brabenetz at infonova.com
Thu Apr 8 13:46:30 CEST 2010
Hi,
I have created a Helper Class:
http://tinyurl.com/y88yyqa
Sources and Jar can be downloaded from (last SNAPSHOT from 6. April):
http://tinyurl.com/yb8jq2k
Example Usage:
---------------------------------------
getCmsObject().lockResource("/testXmlContent.html");
CmsFile file = getCmsObject().readFile("/testXmlContent.html");
XmlContentEditorHelper helper = new XmlContentEditorHelper(
getCmsObject(), file, Locale.ENGLISH);
helper.setValue("Description", "New Description");
helper.removeValue("Title");
helper.removeAllValues("LinkList");
helper.writeContent();
getCmsObject().unlockResource("/testXmlContent.html");
---------------------------------------
regards,
Harald
-----Original Message-----
From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Paul-Inge Flakstad
Sent: Donnerstag, 08. April 2010 10:23
To: The OpenCms mailing list
Subject: Re: [opencms-dev] Remove nodes from a structured XML file
Hi Peter
Our situation is more or less the same as yours - we have a number of news
articles, often several in one day, and we want to show the N latest
articles on the front page.
This is the way we've implemented this:
- each news article is one file (of type "structured content").
- each news article is placed in its permanent location, e.g.
/en/news/2010/02/newsarticle-from-february.html
- on the front page, we list the N latest articles in the sub-tree of
/en/news/
Since we're placing the articles in their permanent location from the very
start, search engines will index the content correctly upon the first crawl,
and we won't create broken links since we don't move the content around.
Not exactly the reply you were looking for perhaps, but I hope it helps you
in some way.
...and if you still want to do it the way you're suggesting, have a look
here, maybe it will give you an idea: http://tinyurl.com/yk74hy5
Best regards,
Paul
> -----Original Message-----
> From: opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Petr Chelcický
> Sent: 8. april 2010 09:43
> To: opencms-dev at opencms.org
> Subject: [opencms-dev] Remove nodes from a structured XML file
>
>
> Hi!
>
> I have a structured XML file which contains news items showed
> on the main page. In order to make this file of a manageable
> size (there are new news items every day), I want to write a
> Java class that would archive older news items and leave only
> 10 latest ones (this class would run as a scheduled task once
> a day) in the file - by archiving I mean moving into another
> file of the same structure. Unfortunately, I haven't found
> appropriate methods in OpenCMS API to do this. Do you have
> any ideas/samples I could look at?
>
> Thanks a lot in advance,
> Peter
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list,
> please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list