2011-03-18 124 views
0

我一直在嘗試讀取DSLR Remote Pro生成的xml文件中的節點,但無法正確顯示它。它不斷返回一個空字符串。我想要做的是從以下XML獲取電子郵件地址。使用AutoHotKey和XPath檢索XML節點值

email.xml

<?xml version="1.0" ?> 
<breeze_systems_photobooth version="1.0"> 
<photo_information> 
    <date>2011/02/24</date> 
    <time>12:55:31</time> 
    <user_data>[email protected]</user_data> 
    <photobooth_images_folder>C:\Program Files\BreezeSys\DSLR Remote Pro\PhotoboothImages\Masquerade_1</photobooth_images_folder> 
    <photos> 
    <photo image="1">IMG_0004.JPG</photo> 
    <output>prints\20110224_125531.jpg</output> 
    </photos> 
</photo_information> 
</breeze_systems_photobooth> 

get_email.ahk

#Include xpath.ahk ; include functions (only required if it is not in your 
standard library) ; parsing 
documents: xml := 
xpath_load("email.xml") ; load an XML 
document email := xpath(xml,"/breeze_systems_photobooth/photo_information/user_data/text()") 
MsgBox, %email% 

缺少什麼我在這裏?

注: 我在WinXP,AutoHotkey的v1.0.92.02和XPath 3.14從https://github.com/polyethene/autohotkey-scripts/raw/master/xpath.ahk

回答

1

的XPath表達式是好的。

你確定文件加載正確嗎?


編輯:你可以嘗試這樣的事情嗎?

xpath_load(xml, "email.xml") 
email := xpath(xml,"/breeze_systems_photobooth/photo_information/user_data/text()") 
+0

據猜測它正確加載,它使用兩個完整的路徑和文件名僅是在同一文件夾中autohokey腳本嘗試。事情是,它返回空。 – Eddy 2011-03-18 07:08:16

+0

不幸的是我不知道AutoHotkey。看到我的編輯在那裏,也許這就是問題... – Ptival 2011-03-18 07:19:30

+0

謝謝!引用了有問題的文檔。 – Eddy 2011-03-18 07:27:10