How can I edit an xml file using java api in Matlab ?

조회 수: 16 (최근 30일)
dblx
dblx 2015년 1월 21일
Hi,
I would like to replace text in an xml file using the org.w3c.dom package in Matlab, specifically the text between help_location
Here is the xml file :
<productinfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="optional">
<?xml-stylesheet type="text/xsl"href="optional"?>
<matlabrelease>2013b</matlabrelease>
<name>Library</name>
<type>other</type>
<icon></icon>
<help_location>C:\Users\user\Desktop\Library/html</help_location>
<help_contents_icon>$toolbox/matlab/icons/bookicon.gif</help_contents_icon>
</productinfo>
and the extract from the m file :
function lib_help_Callback(hObject, eventdata, handles)
% hObject handle to lib_help (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
pwd;
currentfolder = pwd;
xDoc = xmlread(fullfile(('info.xml')));
allListItems = xDoc.getElementsByTagName('productinfo');
allListItems = allListItems.item(0);
thisListItem=allListItems.getElementsByTagName('help_location');
thisListItem=thisListItem.item(0);
textNode = thisListItem.childNodes(0);
textNode.replaceWholeText(currentfolder);
builddocsearchdb(currentfolder);
doc;
do I have to use xmlwrite to overwrite the info.xml file afterwards ? If so please specify how.
Thanks in advance.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Structured Data and XML Documents에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by