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

Error when value attribute is lacking in any option tag of a select #85

Closed
gokceneraslan opened this issue May 11, 2015 · 3 comments
Closed

Comments

@gokceneraslan
Copy link

sel <- '<body>
        <select name="b" id="a">
        <option value="x">x</option>
        <option>y</option>
        </select>
        </body>'
read_html(sel) %>% html_node('select') %>% rvest:::parse_select()

gives

Error in vapply(x, .subset2, i, FUN.VALUE = type) : 
  values must be length 1,
 but FUN(X[[1]]) result is length 0

But

sel <- '<body>
        <select name="b" id="a">
        <option value="x">x</option>
        <option value="y">y</option>
        </select>
        </body>'
read_html(sel) %>% html_node('select') %>% rvest:::parse_select()

works fine:

$name
[1] "b"

$value
character(0)

$options
  x   y 
"x" "y" 

attr(,"class")
[1] "select"

value attribute is not mandatory, is it?

@gokceneraslan
Copy link
Author

@hadley hadley closed this as completed in 21066f2 Sep 23, 2015
@hadley
Copy link
Member

hadley commented Sep 23, 2015

That change just plasters over the problem instead of fixing it - I used some of the new xml2 functions to do better.

@gokceneraslan
Copy link
Author

Thanks!

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