opencms批量建立测试新闻

本文介绍如何使用OpenCms API创建新的HTML文件,并详细展示了如何通过编程方式设置文件内容,包括插入特定的XML结构。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I progress, doing this:


CmsProject p2 = cms_.readProject("myproject"); cms_.getRequestContext().setCurrentProject(p2); String url_xsd = "/system/modules/org.afmbiomed/schemas/article.xsd"; String url_html = "/system/modules/org.afmbiomed/elements/exarticle.html"; String url_acreer = "/system/modules/org.afmbiomed/elements/test.html"; CmsResource cmsr = cms_.createResource(url_acreer, 247); CmsFile cmsf = CmsFile.upgrade(cmsr,cms.getCmsObject());

It create the file test.html

Now I have to find how add the contents!


I only found how to insert full contents:

List properties = new ArrayList(); String contents = "<?xml version=/"1.0/" encoding=/"UTF-8/"?>" + "<Articles xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/" xsi:noNamespaceSchemaLocation=/"opencms://system/modules/mymodule/schemas/article.xsd/">" + "<Article language=/"en/">" + "<Title><!--[CDATA[" + _title + "]]></Title>" + "<Teaser><![CDATA[" + _teaser + "]]></Teaser>" + "<Text name=/"Text0/"><links/><content><![CDATA[<p>" + _text + "</p>]]--></content></Text>" + "</Article></Articles>";CmsResource cmsr = cms_.createResource(url_acreer, myXMLTypeID,contents.getBytes(),properties);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值