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

Question-Add a node #48

Closed
danoyoung opened this issue Feb 4, 2016 · 1 comment
Closed

Question-Add a node #48

danoyoung opened this issue Feb 4, 2016 · 1 comment
Labels

Comments

@danoyoung
Copy link

I'm new to parsing XML, so I may have my terms conflated and not know what the hell I'm talking about.... But I have a xml file like this:

<configuration>
 <property>
    <name>foo1</name>
    <value>bar</value>
  </property>
</configuration>

and I want to add a node, under the parent, so I'll end up having:

<configuration>
 <property>
    <name>foo1</name>
    <value>bar</value>
  </property>

 <property>
    <name>foo1</name>
    <value>baz</value>
  </property>
</configuration>

Is that possible with this library? and if so, any pointers/examples would be greatly appreciated.

@danoyoung danoyoung changed the title Add a node Question-Add a node Feb 4, 2016
@cmprescott
Copy link
Owner

See the unit test for adding children https://github.com/cmprescott/ansible-xml/blob/master/tests/test-add-children-elements.yml
See xpath selecting nth item http://stackoverflow.com/a/4008925/618580

Playing with the unit tests is probably the easiest/quickest way to determine how you can accomplish your use case.

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

2 participants