0
variable=data

How do I extract data? I need to set variable= somehow. Running xidel file.txt -e "variable=" gives error err:XPST0003: Unexpected query end and removing = gives no results.

user3108268
  • 1,043
  • 3
  • 18
  • 37
  • `for /F "tokens=2 delims==" %L in ("variable=data") do set "VALUE=%L"`, then `echo %VALUE%` to display data... – aschipfl Apr 04 '17 at 18:05

1 Answers1

1

Actually xidel is meant to extract data from structured data like xml/html/json with languages like xquery/xpath/templates/jsonic... and is not particularly designed for text based extraction. However, you can toy with $raw and regular expression functions like extract() and replace() to try and get the variable.

So for example, if you have a file.txt with contents like:

var1=one
var2=two
var3=three

you can do the following:

xidel -s file.txt -e "output:=extract($raw,'var2=(.*)',1)"

And the result is:

output := two

Now, assuming you're on windows, you can export this to an environment variable with a for loop and --output-format cmd, like the following link: https://stackoverflow.com/a/38599599/3910330

Community
  • 1
  • 1
MatrixView
  • 311
  • 2
  • 7