General XMetaL Discussion
sapraaman June 14, 2010 at 8:36 am
Xml of cloned node not properJune 14, 2010 at 8:36 amParticipants 1Replies 2Last Activity 12 years ago
If we clone a node using
.cloneNode(true) method, and call .xml method on it, the xml returned has all the attributes, attribute values and all the text represented as entities. This makes the method quite not of much use. The method could be very helpful to us for debugging purposes.
var clonedNode = node.cloneNode(true);
We are using XMetal 5.5
AmanDerek Read June 14, 2010 at 8:08 pm
Reply to: Xml of cloned node not properJune 14, 2010 at 8:08 pm
We did not envision your usage when .xml was implemented here so this just looks like an oversight to me. I'll have development look into it.
In the meantime, I think you can use Range.TextWithRM to get what you need. Here is an example that will need to be modified to give you exactly what you want:
[code]//XMetaL Script Language JScript:
var rng = ActiveDocument.Range;
//Create a node based on current selection. If you have already defined a node object
//called “node” (as in your original script snippet) you won't need this next line.
var node = rng.ContainerNode;
//Move the rng to your node. In this example it is the same place,
//in your case it is probably a different location in the document.
If you are sure there are no revision marks, or do not want to include them you can use rng.Text instead.
For help switching between node representations of “where you are” (DOM) and Selection/Range objects see the Programmer's Guide topic “DOM interfaces” and scroll down to where it says “Working with selections and nodes”.
- You must be logged in to reply to this topic.