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

8 visualizaciones (últimos 30 días)
dblx
dblx el 21 de En. de 2015
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.

Respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by