r-lib / xml2

Bindings to libxml2
https://xml2.r-lib.org/
Other
220 stars 81 forks source link

passsing variable to conditional xpath expression returns null whereas passing value gives result #372

Closed iamihgam closed 1 month ago

iamihgam commented 2 years ago

I have a variable say x which can take any integer value.

When I try to pass the value directly (say, x=0) instead of variable as below, I get respective nodes

root_unitgroup %>% xml_find_all("//*[@dataSetInternalID = '0']")

however, if I pass variable as below , I get empty node, or null value if I use xml_find_first instead .

root_unitgroup %>%  xml_find_all("//*[@dataSetInternalID = '$x']")
hadley commented 1 year ago

Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you! If you've never heard of a reprex before, start by reading about the reprex package, including the advice further down the page. Please make sure your reprex is created with the reprex package as it gives nicely formatted output and avoids a number of common pitfalls.

hadley commented 1 month ago

I've closed this issue due to lack of requested reprex. If you still care about this bug, please open a new issue with a reprex.