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

[XPath] How to get both items? #106

Closed
Shohreh opened this issue Jul 8, 2023 · 2 comments
Closed

[XPath] How to get both items? #106

Shohreh opened this issue Jul 8, 2023 · 2 comments

Comments

@Shohreh
Copy link

Shohreh commented Jul 8, 2023

Hello,

I'm using Xidel for this, but it's actually an XPath question… that I don't where to ask.

I need to grab "FOO" and "BAR" from this div:

<div class="panel-heading collapsed" role="tab">
  <div class="col-xs-1 h_class">
    <label class="label label-warning">FOO</label>
  </div>
  <div class="col-xs-9 name_station">
    BAR
  </div>
</div>

The following works to get FOO, but I haven't found how to get BAR. Anybody knows?

xidel.exe -se "//div[@class='panel-heading collapsed']/div/label/text()" test.html

Thank you.

PS: If you know of a good site/book to learn XPath, I'm interested

@Reino17
Copy link

Reino17 commented Jul 8, 2023

Create a sequence:

xidel -s test.html -e "//div[@class='panel-heading collapsed']/(div/label,div[2])"
FOO

    BAR

"BAR" stripped of white-space:

xidel -s test.html -e "//div[@class='panel-heading collapsed'] ! (div/label,normalize-space(div[2]))"
FOO
BAR

xidel -s test.html -e ^"^
  //div[@class='panel-heading collapsed'] ! (^
    div/label,^
    normalize-space(div[2])^
  )^
"
FOO
BAR

but it's actually an XPath question… that I don't where to ask.

I think the forums, the mailing list, or StackOverflow would be a better place to ask.

PS: If you know of a good site/book to learn XPath, I'm interested

#67 (comment)

And some general XPath/XQuery urls:

@Shohreh
Copy link
Author

Shohreh commented Jul 8, 2023

Thanks!

@Shohreh Shohreh closed this as completed Jul 8, 2023
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