我正在使用Perl XML :: LibXML从XML中提取一些数据。
XML:
<root>
<child1>
<child2>
<common_tag_name>
<name>name_level1_name1</name>
<attribute>
<name>name_level2_name1</name>
<value>some_data1</value>
</attribute>
<attribute>
<name>name_level2_name2</name>
<value>some_data2</value>
</attribute>
<attribute>
<name>name_level2_name3</name>
<value>some_data3</value>
</attribute>
</common_tag_name>
<common_tag_name>
<name>name_level1_name2</name>
<attribute>
<name>name_level2_name1</name>
<value>some_data4</value>
</attribute>
<attribute>
<name>name_level2_name2</name>
<value>some_data5</value>
</attribute>
<attribute>
<name>name_level2_name3</name>
<value>some_data6</value>
</attribute>
</common_tag_name>
</child2>
</child1>
</root>
问题:
查找; if / common_tag_name / name ==“name_level1_name1”和/ common_tag_name / name / attribute / name ==“name_level2_name1”然后提取/ common_tag_name / name / attribute / value,即我应该得到“some_data1”
应该循环读取same_data *
是否可以使用XML :: LibXML?