-1
我需要訪問xml中的所有子元素,如下所示。每一個非空的元素,我都想要它的價值和路徑。這是否有可能?我可以在xml :: simple中寫入手動解析,但它感覺不對。訪問xml文件中的元素和路徑 - PERL
<Incident>
<Organisation>
<USD_Local>Secure Cloud Container</USD_Local>
</Organisation>
<Location/>
<Contact_Reference>
<Organisation>
<USD_Local>Secure Cloud Container</USD_Local>
</Organisation>
<Contact_ID/>
<Contact_Name>
<First_Name/>
<Last_Name/>
</Contact_Name>
<External_Reference>AMZZEMP:000000000152299</External_Reference>
<Freeform_Details/>
<Email_Address/>
</Contact_Reference>
<Requested_By>
<Organisation>
<USD_Local>Secure Cloud Container</USD_Local>
</Organisation>
<Contact_ID/>
<Contact_Name>
<First_Name/>
<Last_Name/>
</Contact_Name>
<External_Reference>AMZZEMP:000000000152299</External_Reference>
<Freeform_Details/>
<Email_Address/>
<Additional_Attribute>Security-AAHPS.Other</Additional_Attribute>
</Requested_By>
<Incident_Type>Incident</Incident_Type>
<Severity>2</Severity>
<Category>
<USD_Local>Security-AAHPS.Other</USD_Local>
<USD_Foreign/>
</Category>
<Service_Type>
<Name/>
<Target_Duration/>
</Service_Type>
<Group>
<USD_Local>UK.Security.SOC</USD_Local>
</Group>
<Configuration_Item action="Add_Link">
<Name>CATPLD2PRSSEN03</Name>
<CI_Number/>
<Serial_Number/>
<System_Name/>
<External_Reference/>
<Additional_Attribute/>
</Configuration_Item>
<Summary>Topbanana</Summary>
<Customer_Reference>SCC</Customer_Reference>
<Supplier_Reference/>
<Occurred_Date_Time format="yyyy/MM/dd HH:mm:ss">2015/04/01 10:50:52</Occurred_Date_Time>
</Incident>
你用什麼模塊? [XML :: Twig](http://p3rl.org/XML::Twig)或[XML :: LibXML](http://p3rl.org/XML::LibXML)? – choroba
爲以前的XML我使用XML :: LibXML和XML ::簡單...但手動提取元素不覺得正確...我也使用XML :: XPath,XML :: XPath:.XMLParser – palyxk
「*每個元素這不是空的,我想有它的價值和路徑,是否有可能這樣?*「是的,這是可能的。請發佈您期望得到的確切代碼。如果您嘗試過任何操作,請將其發佈。如果你沒有,爲什麼不呢? –