【发布时间】:2014-04-23 15:00:02
【问题描述】:
我有我的 xpath 查询的输出,比如使用 phhp 代码 -
<?php
$variable=$_POST['module'];
$xmldoc = new DOMDocument();
$xmldoc->load('info.xml');
$xpathvar = new Domxpath($xmldoc);
$queryResult = $xpathvar->query("testcase[substring-after(
substring-after(script, '/'),
'/'
) = '$variable' or
substring-before(
substring-after(
substring-after(script, '/'),
'/'
),
'/'
) = '$variable']");
foreach($queryResult as $var)
{
echo $var->textContent;
echo "\n";
}
?>
输出 -
Backup_Restore_04_Restore_mode_OFF_Restore 3630976 SDN_CONTROLLER scripts/testSuite/sdnSTC/Flare/Backup_Restore/Sprint16_tests/Backup_Restore_RestoreModeOFFRestore.tcl This test case is to verify Message on Restore mode OFF TCL STC OK 89765 NULL ALL SDN SDN_CONTROLLER target:system:family:stc-auto-workstation-B Backup_restore_05_restore_mode_on_No_Restore_file 3631050 SDN_CONTROLLER scripts/testSuite/sdnSTC/Flare/Backup_Restore/Sprint16_tests/Backup_Restore_RestoreModeOnNORestoreFile.tcl To verify Restore mode ON and there is no backupfile available for Restore and restart flare in normal mode TCL STC OK 89766 NULL ALL SDN SDN_CONTROLLER target:system:family:stc-auto-workstation-B
我想要的是从此输出中获取所有以 .tcl 结尾的字符串。
如何做到这一点。 请帮助..自上周以来我一直卡在这里:(
【问题讨论】:
-
info.xml的数据结构是什么? -
Scuzzy - info.xml 文件在这里 :- xml
-
scuzzy - 你看到我的输出了吗.. 在那个输出中我不能引用这样的脚本,所以我卡住了:(
标签: php xml xpath nsxmlparser