当前位置: 首页 > news >正文

通过hutool生成xml

通过hutool生成如下xml文件
在这里插入图片描述
生成代码:

/**param list :数据库查询到的数据
*/
private static String createXml(List<Map<String, Object>> list) {Document doc = XmlUtil.createXml(); // 5.8+ 方法// ① 根元素(标准 SOAP 命名空间,URI 不能有空格)Element envelope = doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "soapenv:Envelope");envelope.setAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/");envelope.setAttribute("xmlns:impl", "http://mes.baicmotor.com");doc.appendChild(envelope);// ② Headerenvelope.appendChild(doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "soapenv:Header"));// ③ BodyElement body = doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "soapenv:Body");envelope.appendChild(body);// ④ XGB01LIST(放在 impl 命名空间)Element xgbListRoot = doc.createElementNS("http://mes.baicmotor.com", "impl:XGB01LIST");body.appendChild(xgbListRoot);// ⑤ 循环放 <xgbList>(无命名空间,仅属性)for (Map<String, Object> map : list) {Element item = doc.createElementNS(null, "xgbList");item.setAttribute("vihcleType", map.get("vihcleType").toString());item.setAttribute("isGb", map.get("isGb").toString());xgbListRoot.appendChild(item);}String xml = XmlUtil.toStr(doc, false);return xml;}
http://www.dtcms.com/a/486342.html

相关文章:

  • vue.config.js 文件功能介绍,使用说明,对应完整示例演示
  • 无极分期网站临沂做网络优化的公司
  • Vue3的路由Router【7】
  • DOM 实例
  • 网站安全建设需求分析报告重庆有哪些科技骗子公司
  • Springboot AOP Aspect 拦截中 获取HttpServletResponse response
  • 【深度学习理论基础】什么是蒙特卡洛算法?有什么作用?
  • 网站建设商虎小程序就业网站建设
  • 从留言板开始做网站企业网站建设代理加盟
  • USB——UVC简介
  • cocosCreator导出Web-Mobile工程资源加载时间分析
  • SpringCloud系列(53)--SpringCloud Sleuth之zipkin的搭建与使用
  • 虚拟主机做视频网站可以吗网络规划的主要步骤
  • 【sqlite】xxx.db-journal是什么?
  • Ubuntu 搭建 Samba 文件共享服务器完全指南
  • ubuntu server版本安装vmtool
  • 《Redis库基础使用》
  • 网站转应用济南网站优化推广公司电话
  • 探索libsignal:为Signal提供强大加密保障的开源库
  • PIL与OpenCV双线性插值实现差异导致模型精度不够踩坑
  • 逆合成孔径雷达成像的MATLAB算法实现
  • 网站定制建设公司启信宝企业查询官网
  • html案例:制作一个图片水印生成器,防止复印件被滥用
  • 最新版谷歌浏览器集成知笺云阅读器控件介绍
  • 嘉定装饰装修网站企业网络营销青岛
  • break,continue练习题
  • 【Ubuntu 24.04.3 LTS(Noble Numbat)】移动硬盘数据提取操作手册
  • 网站开发需求分析与功能设计互联网线上推广是什么工作
  • 做网站前应该怎么处理微信推广文案范文
  • 35.渗透-.Kali Linux-工具-反弹shell生成器