样例:
public static void main (String[] args){
Element root = document.addElement("adi:ADI2", "http://www.cablelabs.com/VODSchema/default");
root.addNamespace("adi", "http://www.cablelabs.com/VODSchema/adi")
.addNamespace("vod", "http://www.cablelabs.com/VODSchema/vod");
Element metadata1 = root.addElement("adi:OpenGroupAsset").addAttribute("type", "VODRelease").addAttribute("product", "VOD");
Element ams = metadata1.addElement("vod:VODRelease").addAttribute("providerID", "sihua").addAttribute("providerType", "2");
Element kk1 = ams.addElement("adi:AssetLifetime").addAttribute("startDateTime", "2015-04-08 00:00:00").addAttribute("endDateTime", "2065-04-08 00:00:00").addCDATA("测试1");
Element kk2 = ams.addElement("vod:ShowType").addAttribute("ceshi", "123").addCDATA("");
log.info(document.asXML());
}
maven需要的jar包:
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>