# Problem inserting element at top of xml file

**URL:** <https://forum.ansible.com/t/problem-inserting-element-at-top-of-xml-file/38595>\
**Category:** Ansible Project\
**Created:** [November 21, 2023, 7:23pm UTC](https://forum.ansible.com/t/problem-inserting-element-at-top-of-xml-file/38595 "2023-11-21T19:23:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwhimpel](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jwhimpel](https://forum.ansible.com/u/jwhimpel)\
**Post date:** [November 21, 2023, 7:23pm UTC](https://forum.ansible.com/t/problem-inserting-element-at-top-of-xml-file/38595/1 "2023-11-21T19:23:31Z")

</div>

I am trying to learn how to insert a new element after the \<jboss-cli…\> element.

Contents of the xml file

\<?xml version='1.0' encoding='UTF-8'?\> remote+http remote+http xx.xx.xx.xx 9990

This is my task:

- name: Insert element after jboss-cli element  
community.general.xml:  
add\_children:
- “Inserted”  
input\_type: xml  
namespaces:  
x: urn:jboss:cli:3.4  
path: /opt/wildfly/wf29/bin/jboss-cli.xml  
pretty\_print: true  
xpath: “/x:jboss-cli”

When I execute the role containing this task, I get

FAILED! =\> {“changed”: false, “msg”: “Syntax error in xpath expression: /x:jboss-cli/ (Invalid expression)”

How do I insert this new element immediately following the ?  
I’ve tried xpath:“x:”  
I’ve tried xpath: “/”  
I’ve tried xpath: “/x:”

Thanks
