我有一些XML结构如下:
<whatson>
<productions>
<production>
<category>Film</category>
</production>
<production>
<category>Business</category>
</production>
<production>
<category>Business training</category>
</production>
</productions>
</whatson>
Run Code Online (Sandbox Code Playgroud)
我需要选择一个不包含"商业"类别的每个作品(所以这只是本例中的第一个作品).
xpath有可能吗?我尝试过沿着这些方向努力但却无处可去:
//production[not(contains(category,'business'))]
Run Code Online (Sandbox Code Playgroud) 我正在学习 PHP 和 Drupal。我需要引用一个名为 $contexts 的数组中包含的变量。
所以print_r($contexts)给了我这个:
Array (
[context_view_1] => ctools_context Object (
[type] => view
[view] => view Object (
[db_table] => views_view
[result] => Array (
[0] => stdClass Object (
[nid] => 28
[node_data_field_display_field_display_value] => slideshow
)
)
Run Code Online (Sandbox Code Playgroud)
哎哟令人困惑。我想使用 node_data_field_display_field_display_value 变量。我认为我的代码需要像这样,但我知道这是不对的:
if ($contexts['context_view_1']['view']['result'][0]
['node_data_field_display_field_display_value'] == 'slideshow') then do whatever...
Run Code Online (Sandbox Code Playgroud)
谢谢!