简体   繁体   English

为什么此xpath失败

[英]Why this xpath fails

I have the following xml file 我有以下xml文件

<applications>
   <application>
      <forms>
          <questions>
              <first_name>
                   My Name
              </first_name>
          </questions>
      </forms>
    </application>
</applications>

First I have a for each loop which runs through all applications and assigns a variable app to a current application. 首先,我为每个循环运行一个for所有循环,并为当前应用程序分配一个变量应用程序。 Then I test each application like this: 然后,我像这样测试每个应用程序:

<wr:if select="${app}/forms/questions/first_name" notEmpty="true">Print this if succeeded</wr:if>

I am trying to test if there is a text in first_name tag, but in the end I always have empty string, I guess my if does not succeed. 我正在尝试测试first_name标记中是否有文本,但最后我总是有空字符串,我想我的if不会成功。 Do you know if I made a mistake in my xpath? 您知道我的xpath错误吗?

尝试使用text():

<wr:if select="${app}/forms/questions/first_name/text()" notEmpty="true">Print this if succeeded</wr:if>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM