如何在perl中获取xml元素的第一个和最后一个子元素

时间:2013-09-24 13:28:00

标签: xml perl

<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
</note>

当元素名称作为节点

给出时,答案应该是和body

1 个答案:

答案 0 :(得分:3)

使用xshXML::LibXML的包装:

open data.xml ;
ls (/note/*[1] | /note/*[last()]) ;
相关问题