2012-05-22 157 views
-2

我是XPATH的新手。我正在使用Python和libxml模塊來嘗試僅獲取節點,例如<TITLE><TARGET>,但僅限於某些日期之間。例如,當調用python program.py 01/04/12 01/20/12時,我只想在這兩個日期之間有節點,但我無法找出解決這個問題的好方法。也許有一個我可以使用的XPATH表達式。任何人都可以提出解決方案XPATH Python表達式

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE SCAN_LIST_OUTPUT SYSTEM "https://qualysapi.qualys.com/api/2.0/fo/scan/scan_list_output.dtd"> 
<SCAN_LIST_OUTPUT> 
<RESPONSE> 
<DATETIME>2012-02-13T14:54:21Z</DATETIME> 
<SCAN_LIST> 
    <SCAN> 
    <REF>scan/121212112.61291</REF> 
    <TYPE>Scheduled</TYPE> 
    <TITLE><![CDATA[Company A 5/19/2012]]></TITLE> 
    <USER_LOGIN>username</USER_LOGIN> 
    <LAUNCH_DATETIME>2012-05-20T04:10:05Z</LAUNCH_DATETIME> 
    <STATUS> 
     <STATE>Finished</STATE> 
    </STATUS> 
    <TARGET><![CDATA[10.1.1.1, 10.1.1.1, 10.1.1.1, 10.1.1.1...]]></TARGET> 
    </SCAN> 
    <SCAN> 
    <REF>scan/12121212.1212</REF> 
    <TYPE>Scheduled</TYPE> 
    <TITLE><![CDATA[Company B 5/19/2012]]></TITLE> 
    <USER_LOGIN>username</USER_LOGIN> 
    <LAUNCH_DATETIME>2012-05-19T04:10:06Z</LAUNCH_DATETIME> 
    <STATUS> 
     <STATE>Finished</STATE> 
    </STATUS> 
    <TARGET><![CDATA[10.2.2.2, 10.2.3.3, 10.2.14.5, 10.1.2...]]></TARGET> 
    </SCAN> 

回答