Effacer les filtres
Effacer les filtres

How to find and replace .tif in XML file In MATLAB

4 vues (au cours des 30 derniers jours)
Hammad Younas
Hammad Younas le 6 Mar 2023
Hello, I hope you are doing well. I have the following XML files in folder.
I want to read all files from folder and read the file and change the file extenstion .tif with jpg in XML file.
as you can se below i have the following like where image is in .tif i want to convert end .tif with jpg
Can anybody help me with this.
I have used Notepad++ for this
The xml file is not attaching so i can paste the input of .XML file
<?xml version="1.0"?>
<annotation>ESRI ArcGIS Pro</annotation>

Réponses (1)

Luca Ferro
Luca Ferro le 6 Mar 2023
Try this:
xmlFileDOM = xmlread('totallyAXml.xml'); %reads xml to dom
xmlFileStr=string(xmlwrite(xmlFileDOM)); %cast dom to string
newXML=strrep(xmlFileStr,'.tif','.jpg');%changes tif to jpg
fID=fopen('totallyAXml.xml','w'); %opens xml
fprintf(fID,newXML); %overwrites
fclose(fID); %close and save




Community Treasure Hunt

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

Start Hunting!

Translated by