我一直在尝试读取从DSLR Remote Pro生成的xml文件中的节点,但还是无法正确使用它。它不断返回一个空字符串。我想要做的是从以下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>test@domain.com</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和来自https://github.com/polyethene/autohotkey-scripts/raw/master/xpath.ahk的XPath 3.14
答案 0 :(得分:1)
XPath表达式很好。
您确定文件加载正确吗?
xpath_load(xml, "email.xml")
email := xpath(xml,"/breeze_systems_photobooth/photo_information/user_data/text()")
答案 1 :(得分:0)
对我来说问题是我的XML文件中有注释,显然xpath不能很好地处理注释。
此外,似乎不再支持xpath:xpath no longer supported