作者redhat1980 (家庭公用ID XD)
看板Perl
標題[問題] xml取出TAG值並rename檔名
時間Fri Apr 12 00:49:59 2013
大家好,小弟有1000多個xml,檔名不定;xml結構相同
想要取出patientid 此TAG的值並rename原檔案為 000000001C.xml,
不知道是否可以指導一下小弟,非常感謝...
file name:00b8e600-6875-11e1-4823-0019ddde0029.xml
<patient criteriaversionforpatientdata="0A">
<generalpatientdata>
<patientid>000000001C</patientid>
<uniquepatientid/>
<name>
<lastname>中文字</lastname>
<firstname>
</firstname>
<middlename/>
</name>
<age defaultage="50">
<dateofbirth>1953-10-14</dateofbirth>
</age>
<pacestatus>Unknown</pacestatus>
<sex>Male</sex>
<height>
<cm/>
</height>
<weight>
<kg/>
</weight>
</generalpatientdata>
<patientmedicaldata>
<bloodpressure>
<systolic>
<mmHg/>
</systolic>
<diastolic>
<mmHg/>
</diastolic>
</bloodpressure>
</patientmedicaldata>
</patient>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.170.221.132
1F:推 mmonkeyboyy:XML:Simple 04/12 03:02
2F:推 mmonkeyboyy:拿出ID就可以了 另一種蠢方法就一行一行讀 04/12 03:05
3F:→ iFEELing:一邊讀檔一邊RENAME要小心可能會炸... 04/14 15:06
4F:推 mmonkeyboyy:建新檔再 system 'rm xxxxx' 04/15 20:59