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

"TypeError: Argument 'element' has incorrect type (expected lxml.etree._Element, got _ElementStringResult)" when trying to retrieve attribute value #14

Closed
Lx opened this issue May 2, 2015 · 5 comments
Labels

Comments

@Lx
Copy link

Lx commented May 2, 2015

I'm using the following Ansible task in an attempt to retrieve a value from a remote-side XML file:

- name: try to get existing XML value
  xml: >
    file=/home/XXX/settings.xml
    xpath='/settings/setting[@id="setting.setting_key"]/@value'
    print_match=true
  register: existing_xml_value

The task fails with this output:

TASK: [playbook | try to get existing XML value] ************************ 
failed: [XXX] => {"failed": true, "parsed": false}
BECOME-SUCCESS-XXX
Traceback (most recent call last):
  File "/home/XXX/.ansible/tmp/ansible-tmp-XXX/xml", line 1937, in <module>
    main()
  File "/home/XXX/.ansible/tmp/ansible-tmp-XXX/xml", line 290, in main
    print_match(x, xpath, module)
  File "/home/XXX/.ansible/tmp/ansible-tmp-XXX/xml", line 100, in print_match
    match_xpaths.append(tree.getpath(m))
TypeError: Argument 'element' has incorrect type (expected lxml.etree._Element, got _ElementStringResult)
OpenSSH_XXX, OpenSSL XXX XXX
debug1: Reading configuration data /home/XXX/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 2
Shared connection to XXX closed.

I may be doing it wrong as there's no explicit documentation at this time for retrieving actual values (as opposed to counts). Is this operation supported?

I would guess that the OpenSSH output in the module error output is a module bug, since no other module I've worked with has such output when it fails.

@Lx
Copy link
Author

Lx commented May 2, 2015

(I've referenced this issue from a GitHub Gist for an XML lookup plug-in.)

@jdatx
Copy link

jdatx commented May 18, 2015

I've also not gotten this to work either

@dagwieers
Copy link
Collaborator

The xml module is upstream now (and ships with Ansible v2.4).

Please close this issue, and retest against the new upstream xml module. If needed, open a new issue at: https://github.com/ansible/ansible/issues

@dagwieers
Copy link
Collaborator

I would need to have the content of the XML file in order to test what you're doing.

@cmprescott
Copy link
Owner

Closing issue since hasn't been addressed in 2 years.

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

No branches or pull requests

4 participants