General XMetaL Discussion
pooh2583 February 19, 2013 at 5:41 am
How to copy a node and insert it into a specific positionFebruary 19, 2013 at 5:41 amParticipants 1Replies 2Last Activity 9 years, 11 months ago
I need to copy a specific node from an Xmetal document and insert the same node at a valid place in the same xml document,
I wnt to copy this whole node which is present somewhere in the document and i want to paste/insert the same node at a plce
I need to have same contents in the new node as that of copied node.
please reply how to achieve this.
RegardsDerek Read February 19, 2013 at 8:46 pm
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.
element? Look for an attribute value? Specific content?
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).
- You must be logged in to reply to this topic.