我正在尝试修改具有XML语法的文件
<!DOCTYPE xml>
<lrf instance_prefix="U" pdescription="Type:%20DDR2%20SDRAM;
Density:%204Gb;
Data:%20x16;
Banks:%208;
Configuration:%2016M%20x%2016%20x%208;
Voltage:%201.8V;
Standard:%20JEDEC;
Pins:%2084;
Package:%20FBGA;
Package%20Standard:%20MO-207;%20Package%20Variation:%20DK-z;
Die:%20Single%20Die(SD)%20Package;
Target%20Device%20Family:%20Virtex-7;" unit="mm" target_family="V7" jedec_type="ddr2_sdram_mo207_dk_z" y_offset="0" interface_type="NormalInterface" x_offset="0" model_constraint="same_vccaux" pin_size="0.45">
<group group_number="1" group_name="Address_Control" group_constraint="memory_address" group_color="#9accff">
<pin pin_number="M8" pin_type="Input" pin_standard="SSTL18_II" pin_x_loc="5.6" signal_name="A<0>" pin_y_loc="2.4" symbol_pin_name="DDR2_SDRAM_A<0>"/>
<pin pin_number="M3" pin_type="Input" pin_standard="SSTL18_II" pin_x_loc="1.6" signal_name="A<1>" pin_y_loc="2.4" symbol_pin_name="DDR2_SDRAM_A<1>"/>
.
.
.
</group>
<group group_number="4" group_name="Power" group_color="#ff0000">
<pin pin_number="A1" pin_type="Supply" pin_voltage="1.8" pin_x_loc="0" signal_name="VDD" pin_y_loc="11.2" symbol_pin_name="VDD"/>
<pin pin_number="E1" pin_type="Supply" pin_voltage="1.8" pin_x_loc="0" signal_name="VDD" pin_y_loc="8" symbol_pin_name="VDD"/>
<pin pin_number="J9" pin_type="Supply" pin_voltage="1.8" pin_x_loc="6.4" signal_name="VDD" pin_y_loc="4.8" symbol_pin_name="VDD"/>
.
.
.
</group>
.
.
</lrf>
我的任务是查找值为“VDD”的signal_name,如果存在,则删除整个<pin .... />
节点。如果在上述任务之后组节点中没有可用元素,则删除<group....> </group>
节点。
我使用XML :: Simple尝试过这个任务,但是顺序随着元素不断变化。所以,我正在尝试使用XML :: LibXML完成任务。任何人都可以了解如何使用LibXML完成任务。任何帮助深表感谢。感谢