0

我一直在尝试读取从 DSLR Remote Pro 生成的 xml 文件中的节点,但还不能正确完成。它一直返回一个空字符串。我想要做的是从以下 xml 中获取电子邮件地址。

电子邮件.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%

我在这里想念什么?

注意:我使用的是来自https://github.com/polyethene/autohotkey-scripts/raw/master/xpath.ahk的 WinXP、AutoHotKey v1.0.92.02 和 XPath 3.14

4

2 回答 2

1

XPath 表达式很好。

你确定文件加载正确吗?


编辑:你能试试这样的东西吗?

xpath_load(xml, "email.xml")
email := xpath(xml,"/breeze_systems_photobooth/photo_information/user_data/text()")
于 2011-03-18T07:06:00.090 回答
0

对我来说问题是我的 XML 文件中有注释,显然 xpath 不能很好地处理注释。

此外,似乎不再支持 xpath:xpath 不再支持

于 2014-07-31T20:35:52.677 回答