Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any more examples for xquery? #67

Open
ralyodio opened this issue Jan 29, 2021 · 4 comments
Open

any more examples for xquery? #67

ralyodio opened this issue Jan 29, 2021 · 4 comments

Comments

@ralyodio
Copy link

I can't find much online. I'm trying to parse html and convert to json with some massaging.

@ralyodio
Copy link
Author

ralyodio commented Feb 7, 2021

For some reason I'm not getting the <ticker> tag in the output, just the raw values. Am I misunderstanding how this should work?

#!/usr/bin/env sh

xidel -s https://www.marketbeat.com/short-interest/ --xquery '
for $row in //tbody/tr
	let $ticker := $row//td[1]//div[@class="ticker-area"]
	return <ticker>{$ticker}</ticker>
'


@Reino17
Copy link

Reino17 commented Feb 8, 2021

You're probably looking for:

xidel -s https://www.marketbeat.com/short-interest --xquery '
  for $ticker in //tbody/tr/td[1]//div[@class="ticker-area"]/text() return
  <ticker>{$ticker}</ticker>
' --output-format=xml

Or perhaps:

xidel -s https://www.marketbeat.com/short-interest --xquery '
  serialize(
    <xml>{
      for $ticker in //tbody/tr/td[1]//div[@class="ticker-area"]/text() return
      <ticker>{$ticker}</ticker>
    }</xml>,
    {"indent":true(),"omit-xml-declaration":false()}
  )
'

@ralyodio
Copy link
Author

ralyodio commented Feb 8, 2021

ahh ok, that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants