doc1 <- am_create()
doc2 <- am_create()
# Make changes in each document
am_put(doc1, AM_ROOT, "x", 1)
am_put(doc2, AM_ROOT, "y", 2)
# Merge doc2's changes into doc1
am_merge(doc1, doc2)
# Now doc1 has both x and y
am_close(doc1)
am_close(doc2)
Run the code above in your browser using DataLab