Pages: 1
Print
Author Topic: Xml of cloned node not proper  (Read 899 times)
sapraaman
Member

Posts: 17


« on: June 14, 2010, 02:36:01 AM »

Hi,

If we clone a node using <Node>.cloneNode(true) method, and call <clonedNode>.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.

Code:
var clonedNode = node.cloneNode(true);
Application.Alert(clonedNode.xml);

We are using XMetal 5.5

Thanks,
Aman
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1552



WWW
« Reply #1 on: June 14, 2010, 02:08:22 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.
rng.SelectNodeContents(node);
rng.SelectElement();
Application.Alert(rng.TextWithRM);

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".
http://na.justsystems.com/webhelp/en/xmetaldeveloper/pg/6.0/pg.html#DOM%20interfaces
Logged
sapraaman
Member

Posts: 17


« Reply #2 on: June 16, 2010, 02:59:31 AM »

Thanks Derek for the tip.
Logged
Pages: 1
Print
Jump to:  

email us