有人成功将xidel输出vars导出到cmd吗? [英] Has anyone successfully exported xidel output vars to cmd?

查看:141
本文介绍了有人成功将xidel输出vars导出到cmd吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用xidel从XML文件中的特定标签提取值,然后将其作为var导出到cmd。但是,var似乎根本没有导出。

I'm using xidel to extract a value from a specific tag in a XML file, and export it as a var to cmd. However, the vars don't seem to be exported at all.

示例我正在使用:

xidel in.xml -e {var1:= text()} --output-format cmd

xidel "in.xml" -e "{var1:=text()}" --output-format cmd

我得到输出:

**** Retrieving:in.xml ****  
**** Processing: in.xml ****  
** Current variable state: **  
SET var1=1234  

(其中1234包含在in.xml中)
,但未将var1设置为在命令提示符窗口中可用的变量。
这是在Windows 7计算机上。任何见解将不胜感激-我不知道我是否使用了xidel错误或cmd var输出存在错误。

(where 1234 is contained in in.xml) but var1 is not set as a variable available from the command prompt window. This is on a Windows 7 machine. Any insight would be much appreciated - I don't know if I'm using xidel incorrectly or there's a bug with cmd var output.

推荐答案

不,您没有正确使用Xidel。

首先,使Xidel变量在cmd中可用的唯一方法是使用FOR循环。

其次,在这种情况下,您不应将查询用大括号括起来。

第三,正式地,它是-output-format = cmd ,但是我想Benito-Xidel的作者-一直为那些忘记 = 的人宽恕,因为-输出格式cmd 似乎也能正常工作。如果您使用 = ,请不要忘记使用 ^ 对其进行转义,因为这是一个特殊字符

No, you're not using Xidel correctly.
First of all, the only way to make Xidel variables available in cmd is through the use of a FOR-loop.
Secondly, in this situation you shouldn't enclose your query with curly brackets. Those are meant for creating JSONs, amongst other things.
And thirdly, officially it's --output-format=cmd, but I guess Benito - Xidel's author - has been forgiving for people who forget the =, as --output-format cmd seems to work as well. Should you use the =, don't forget to escape it with a ^, because it's a special character.

因此,您的FOR循环如下所示:

So your FOR-loop would then look like this:

FOR /F "delims=" %%A IN ('xidel.exe -s "in.xml" -e "var1:=..." --output-format^=cmd') DO %%A

这篇关于有人成功将xidel输出vars导出到cmd吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆