【发布时间】:2013-04-07 22:29:58
【问题描述】:
我需要将 XML 文件解析为 Ruby 对象。
有没有像这样从 XML 中读取属性的工具
report.system_slots.items 返回项目属性数组,
或report.system_slots.current_usage 返回“可用”?
Nokogiri 可以做到这一点吗?
<page Title="System Slots" H1="Property" H2="Value" __type__="2">
<item Property="System Slot 1">
<item Property="Name" Value="PCI1"/>
<item Property="Type" Value="PCI"/>
<item Property="Data Bus Width" Value="32 bits"/>
<item Property="Current Usage" Value="Available"/>
<item Property="Characteristics">
<item Property="Vcc voltage supported" Value="3.3 V, 5.0 V"/>
<item Property="Shared" Value="No"/>
<item Property="PME Signal" Value="Yes"/>
<item Property="Support Hot Plug" Value="No"/>
<item Property="PCI slot supports SMBus signal" Value="Yes"/>
</item>
</item>
【问题讨论】:
标签: ruby xml xml-parsing nokogiri