- 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 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
- -->
原文链接:地址