[英]Error on createTextNode MATLAB 2015b XMLUtils
我將一些數據寫入XML文件:
[FileName,PathName] = uiputfile('*.xml','Select the XML file');
if length(FileName) > 3
completePath = [PathName FileName];
% Create the DOM-Object
docNode = com.mathworks.xml.XMLUtils.createDocument('docRootNode');
docRootNode = docNode.getDocumentElement;
docRootNode.setAttribute('version','2.0');
mElement = docNode.createElement('Data1');
docRootNode.appendChild(mElement)
fields = fieldnames(struct1);
for i = 1:numel(fields)
thisElement = docNode.createElement(fields{i});
thisElement.appendChild...
(docNode.createTextNode(struct1.(fields{i}))); %NO ERROR
mElement.appendChild(thisElement);
end
rElement = docNode.createElement('Data2');
docRootNode.appendChild(rElement)
fields = fieldnames(struct2);
for i = 1:numel(fields)
thisElement = docNode.createElement(fields{i});
thisElement.appendChild...
(docNode.createTextNode(struct2.(fields{i}))); %ERROR
rElement.appendChild(thisElement);
end
xmlwrite(completePath, docNode);
end
上周它可以正常工作,但是從今天開始,我在運行%ERROR
代碼行中收到此錯誤:
沒有為類“ org.apache.xerces.dom.DocumentImpl”找到具有匹配簽名的方法“ createTextNode”。
我在互聯網上找不到任何解決方案(問題可能是我不是PC上的管理員)。
我也不明白,為什么我的上半部分沒有錯誤( %NO ERROR
)
我的問題在MATLAB的支持下得以解決:
我程序中的唯一問題是struct2
包含整數值。
struct1
僅包含字符串值,因此沒有問題。
我現在使用num2str
轉換數值,並且沒有任何問題;)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.