我是靠谱客的博主 淡定高跟鞋,这篇文章主要介绍matlab写xml文件,写入 XML 文档对象模型节点,现在分享给大家,希望可以做个参考。

分两步编写 XML 文件。首先,创建一个包含 XML 数据的文档对象模型 (DOM) 节点。然后,将该 DOM 节点写入一个 XML 文件。最终的 XML 文件应该包含以下文本。

Upslope Area Toolbox

demFlow

facetFlow

flowMatrix

pixelFlow

首先,创建 DOM 节点对象和根元素,然后根据 XML 数据填充节点元素和节点属性。

docNode = com.mathworks.xml.XMLUtils.createDocument('toc');

确定根元素并设置 version 属性。

toc = docNode.getDocumentElement;

toc.setAttribute('version','2.0');

为产品页添加 tocitem 元素。此文件中的每个 tocitem 元素都有一个 target 属性和一个子文本节点。

product = docNode.createElement('tocitem');

product.setAttribute('target','upslope_product_page.html');

product.appendChild(docNode.createTextNode('Upslope Area Toolbox'));

toc.appendChild(product);

添加注释。

product.appendChild(docNode.createComment(' Functions '));

为每个函数添加一个 tocitem 元素,其中 target 为 function_help.html 形式。

functions = {'demFlow','facetFlow','flowMatrix','pixelFlow'};

for idx = 1:numel(functions)

curr_node = docNode.createElement('tocitem');

curr_file = [functions{idx} '_help.html'];

curr_node.setAttribute('target',curr_file);

% Child text is the function name.

curr_node.appendChild(docNode.createTextNode(functions{idx}));

product.appendChild(curr_node);

end

最后,将该 DOM 节点导出到名为 infoUAT.xml 的 XML 文件中,并使用 type 函数查看该文件。

xmlwrite('infoUAT.xml',docNode);

type('infoUAT.xml');

Upslope Area ToolboxdemFlow

facetFlow

flowMatrix

pixelFlow

最后

以上就是淡定高跟鞋最近收集整理的关于matlab写xml文件,写入 XML 文档对象模型节点的全部内容,更多相关matlab写xml文件,写入内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部