【sos】matlab读xml读不到属性值,何解?
matlab吧
全部回复
仅看楼主
level 6
果果🍁 楼主
<?xml version="1.0"?>
<!DOCTYPE network SYSTEM "network.dtd">
<network locale="C" version="1.6" attribute_processing="explicit">
<subnet name="Office Network">
<node name="mobile_node_0" model="WSN_node" mobility="mobile" ignore_questions="true" min_match_score="strict matching">
<attr name="x position" value="0"/>
<attr name="x position" value="0"/>
<attr name="y position" value="0"/>
<attr name="color" value="white"/>
<attr name="bearing" value="0.0"/>
<attr name="ground speed" value=""/>
<attr name="ascent rate" value=""/>
<attr name="threshold" value="0.0"/>
<attr name="icon name" value="mobile_comm"/>
<attr name="doc file" value=""/>
<attr name="tooltip" value=""/>
<attr name="creation source" value="Object copy"/>
<attr name="creation timestamp" value="10:07:15 Feb 27 2013"/>
<attr name="creation data" value="Copy of mobile_node_0"/>
<attr name="pitch" value="0.0"/>
<attr name="yaw" value="0.0"/>
<attr name="roll" value="0.0"/>
<attr name="label color" value="black"/>
<attr name="altitude" value="2.0"/>
<attr name="802_15_4_mac.Channel Sensing Duration" value="0.1"/>
<attr name="802_15_4_mac.Data Rate" value="Auto Calculate" symbolic="true"/>
<attr name="802_15_4_mac.Packet Reception-Power Threshold" value="-85" symbolic="true"/>
<attr name="network_layer.Address" value="Auto Assign" symbolic="true"/>
<attr name="network_layer.Device Type" value="PAN Coordinator" symbolic="true"/>
<attr name="network_layer.PAN ID" value="2"/>
<attr name="wireless_tx.channel [0].power" value="0.05"/>
</node>
</subnet>
</network>
上面是部分xml代码,我想读取 attr中的value值
以下是我的操作
xDoc=xmlread('top1.xml')
allListItems = xDoc.getElementsByTagName('node');
thisList = thisListItem.getElementsByTagName('attr');
thisList.item(0).getAttributes.item(1).getValue
最后一步可以得到x position的值,value值怎么获取?
2014年04月03日 09点04分 1
1