赞
踩
<?xml version="1.0" encoding="utf-8"?>
<info>
<name>Jack</name>
<gender>male</gender>
<address>Beijing</address>
<phone>
<mobilephone>123456</mobilephone>
<landline>012345</landline>
</phone>
</info>
代码如下:
% read xml
xmlDoc = xmlread('info.xml');
% name node
name_array = xmlDoc.getElementsByTagName('name');
name = char(name_array.item(0).getTextContent());
disp(['name:' name]);
% phone element
phone_array = xmlDoc.getElementsByTagName('phone');
phone = phone_array.item(0);
disp([char(phone.item(1).getNodeName()) ':' char(phone.item(1).getTextContent())]);
disp([char(phone.item(3).getNodeName()) ':' cha
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。