Home › Forums › General XMetaL Discussion › How to copy a node and insert it into a specific position › Reply To: How to copy a node and insert it into a specific position
Reply to: How to copy a node and insert it into a specific positionFebruary 19, 2013 at 8:46 pm
Please describe the exact steps your code needs to perform so I can try to write an example.
Something like this:
1) Select the current element. If not the current element then how do we find it? Look for the first/second/third/etc.
2) Copy the whole node. How? To the clipboard? By duplicating it without modifying the clipboard?
3) It sort of sounds like you want to modify what was copied. If so, what is changing exactly?
4) Move the insertion point (cursor) after some other element. What criteria do we use to find the element (name, location)?
5) Insert what was copied (and possibly modified).
APIs to look at in the Programmers Guide include:
…and all of the various Range methods related to moving around the document.
You can also do this with the DOM APIs. However, DOM is a more difficult concept to grasp (especially for people just beginning to write macros) so I would avoid using it unless you have some very specific need (it will be rare to find something you cannot do with Range/Selection that you can only do with DOM).