#15 How to insert a new element under another with xmlstarlet?

closed
nobody
7
2011-05-25
2011-05-11
Gabriele
No

REPOST: http://stackoverflow.com/questions/5954168/how-to-insert-a-new-element-under-another-with-xmlstarlet

$ vim test.xml

<?xml version="1.0" encoding="UTF-8" ?>
<config>
</config>
$ xmlstarlet ed -i "/config" -t elem -n "sub" -v "" test.xml
<?xml version="1.0" encoding="UTF-8"?>
<sub></sub>
<config>
</config>

But I wanted sub to be a child of config. How should I change the xpath parameter of -i?

Discussion

  • Gabriele

    Gabriele - 2011-05-11
    • priority: 5 --> 7
     
  • Noam Postavsky

    Noam Postavsky - 2011-05-11

    You should use -s (or --subnode) instead of -i.

     
  • Noam Postavsky

    Noam Postavsky - 2011-05-11
    • status: open --> pending
     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending --> closed
     

Log in to post a comment.