matlab生成xml文件代码示例
2016-07-26 14:31
561 查看
tempname = 'myxml';
docNode = com.mathworks.xml.XMLUtils.createDocument('obj')
docRootNode = docNode.getDocumentElement;
%docRootNode.setAttribute('attr_name','attr_value');
IDNode = docNode.createElement('ID');
IDNode.appendChild(docNode.createTextNode(sprintf('%i',5)));
docRootNode.appendChild(IDNode);
objNmNode = docNode.createElement('objNm');
objNmNode.appendChild(docNode.createTextNode(sprintf('plane####################1008')));
docRootNode.appendChild(objNmNode);
thisElement = docNode.createElement('FDs');
docRootNode.appendChild(thisElement);
dataNode = docNode.createElement('FD1');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD2');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD3');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD4');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
thisElement = docNode.createElement('FD_Clusters');
docRootNode.appendChild(thisElement);
dataNode = docNode.createElement('FD_Clusters1');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD_Clusters2');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD_Clusters3');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD_Clusters4');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
FD_histoNode = docNode.createElement('FD_histogram');
FD_histoNode.appendChild(docNode.createTextNode(sprintf('17 10 8 5 3 2 1 ')));
docRootNode.appendChild(FD_histoNode);
docNode.appendChild(docNode.createComment('this is a comment'));
xmlFileName = [tempname,'.xml'];
xmlwrite(xmlFileName,docNode);
type(xmlFileName);
生产XML文件如下:
[html] view
plain copy
<? xml version="1.0" encoding="utf-8" ?>
- < obj >
< ID > 5 </ ID >
< objNm > plane####################1008 </ objNm >
- < FDs >
< FD1 > 4 43 3 32 1 6 0 3 1 2 </ FD1 >
< FD2 > 4 43 3 32 1 6 0 3 1 2 </ FD2 >
< FD3 > 4 43 3 32 1 6 0 3 1 2 </ FD3 >
< FD4 > 4 43 3 32 1 6 0 3 1 2 </ FD4 >
</ FDs >
- < FD_Clusters >
< FD_Clusters1 > 4 43 3 32 1 6 0 3 1 2 </ FD_Clusters1 >
< FD_Clusters2 > 4 43 3 32 1 6 0 3 1 2 </ FD_Clusters2 >
< FD_Clusters3 > 4 43 3 32 1 6 0 3 1 2 </ FD_Clusters3 >
< FD_Clusters4 > 4 43 3 32 1 6 0 3 1 2 </ FD_Clusters4 >
</ FD_Clusters >
< FD_histogram > 17 10 8 5 3 2 1 </ FD_histogram >
</ obj >
<!--
this is a comment
-->
原文链接:地址
docNode = com.mathworks.xml.XMLUtils.createDocument('obj')
docRootNode = docNode.getDocumentElement;
%docRootNode.setAttribute('attr_name','attr_value');
IDNode = docNode.createElement('ID');
IDNode.appendChild(docNode.createTextNode(sprintf('%i',5)));
docRootNode.appendChild(IDNode);
objNmNode = docNode.createElement('objNm');
objNmNode.appendChild(docNode.createTextNode(sprintf('plane####################1008')));
docRootNode.appendChild(objNmNode);
thisElement = docNode.createElement('FDs');
docRootNode.appendChild(thisElement);
dataNode = docNode.createElement('FD1');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD2');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD3');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD4');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
thisElement = docNode.createElement('FD_Clusters');
docRootNode.appendChild(thisElement);
dataNode = docNode.createElement('FD_Clusters1');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD_Clusters2');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD_Clusters3');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
dataNode = docNode.createElement('FD_Clusters4');
dataNode.appendChild(docNode.createTextNode(sprintf('4 43 3 32 1 6 0 3 1 2 ')));
thisElement.appendChild(dataNode);
FD_histoNode = docNode.createElement('FD_histogram');
FD_histoNode.appendChild(docNode.createTextNode(sprintf('17 10 8 5 3 2 1 ')));
docRootNode.appendChild(FD_histoNode);
docNode.appendChild(docNode.createComment('this is a comment'));
xmlFileName = [tempname,'.xml'];
xmlwrite(xmlFileName,docNode);
type(xmlFileName);
生产XML文件如下:
[html] view
plain copy
<? xml version="1.0" encoding="utf-8" ?>
- < obj >
< ID > 5 </ ID >
< objNm > plane####################1008 </ objNm >
- < FDs >
< FD1 > 4 43 3 32 1 6 0 3 1 2 </ FD1 >
< FD2 > 4 43 3 32 1 6 0 3 1 2 </ FD2 >
< FD3 > 4 43 3 32 1 6 0 3 1 2 </ FD3 >
< FD4 > 4 43 3 32 1 6 0 3 1 2 </ FD4 >
</ FDs >
- < FD_Clusters >
< FD_Clusters1 > 4 43 3 32 1 6 0 3 1 2 </ FD_Clusters1 >
< FD_Clusters2 > 4 43 3 32 1 6 0 3 1 2 </ FD_Clusters2 >
< FD_Clusters3 > 4 43 3 32 1 6 0 3 1 2 </ FD_Clusters3 >
< FD_Clusters4 > 4 43 3 32 1 6 0 3 1 2 </ FD_Clusters4 >
</ FD_Clusters >
< FD_histogram > 17 10 8 5 3 2 1 </ FD_histogram >
</ obj >
<!--
this is a comment
-->
原文链接:地址
相关文章推荐
- 基于matlab的图像hough变换
- matlab写数据到txt文件,C语言读取文件内容到数组@项目简介:基于PSS序列(频域)估计整数倍频偏
- Matlab函数大全
- 大数据基础(六) Matlab R2015b MDCE分布式计算环境搭建
- Matlab查找当前目录及子目录下所有文件
- C#与matlab的混合编程
- Ubuntu下matlab快捷键设置
- MATLAB读取UCI数据集,excel 为中介工具
- Matlab 读取excel文件提示服务器出现意外情况或无法读取问题解决
- MATLAB cell 数组介绍
- 用Matlab实现字符串分割(split)
- matlab字符串处理
- Matlab与C++混合编程(依赖OpenCV)
- Matlab、C++、OpenCV混合编程
- Matlab实现将excel文件数据写到txt文件中
- Matlab批量预处理图片
- Java调用Matlab
- 增加回溯的最短路径算法的matlab实现
- fprintf函数小记
- 买西瓜的高级玩法,用好你的智能手机