使用AutoHotKey和XPath检索XML节点值
问题描述:
我一直在尝试读取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
答
的XPath表达式是好的。
你确定文件加载正确吗?
编辑:你可以尝试这样的事情吗?
xpath_load(xml, "email.xml")
email := xpath(xml,"/breeze_systems_photobooth/photo_information/user_data/text()")
据猜测它正确加载,它使用两个完整的路径和文件名仅是在同一文件夹中autohokey脚本尝试。事情是,它返回空。 – Eddy 2011-03-18 07:08:16
不幸的是我不知道AutoHotkey。看到我的编辑在那里,也许这就是问题... – Ptival 2011-03-18 07:19:30
谢谢!引用了有问题的文档。 – Eddy 2011-03-18 07:27:10