matlab读取xml文件

xml文件

(%后面的是注释,可删除)

<?xml version="1.0" encoding="UTF-8"?>
<Ipf_Job_Order>
  <Ipf_Conf>
      <Processing_Parameter>   %输入参数
        <Name>OutputType</Name>  %参数名
        <Value>0</Value>                    %参数
      </Processing_Parameter>
  </Ipf_Conf>
  <List_of_Ipf_Procs>
    <Ipf_Proc>
      <List_of_Inputs>
        <Input>
          <List_of_File_Names>   %输入文件路径(这里是图片)
            <File_Name>D:\acode\areef_change detection\geotiff\yx2015.tif </File_Name>   %图片  注意:</File_Name>之间不要空格
            <File_Name>D:\acode\areef_change detection\geotiff\yx2016.tif </File_Name>   %图片2
          </List_of_File_Names>
        </Input>
      </List_of_Inputs>
    </Ipf_Proc>
  </List_of_Ipf_Procs>
</Ipf_Job_Order>

matlab读取xml文件

%% read xml
xmlDoc = xmlread('inputParams.xml');

% 参数读取
name_array = xmlDoc.getElementsByTagName('Value');
th = char(name_array.item(0).getTextContent());
t=str2double(th);               %参数格式转换:str转为double型

% 图像路径读取
name_array = xmlDoc.getElementsByTagName('List_of_File_Names');
name = name_array.item(0);
name1=char(name.item(1).getTextContent());
name2=char(name.item(3).getTextContent());    %注意:不能是(2),(2)为回车(猜测)
 

可参考博文https://blog.csdn.net/lkj345/article/details/52763790

猜你喜欢

转载自blog.csdn.net/qq_39620453/article/details/91814791
今日推荐