Because you say the XML is read-only, I think your first issue is that
you're trying to make the change in onBeforeChange. All XML is read-only
there; you should use onAfterChange if you want to set data after a user
modification.
Here's some sample code to help you out. You'll have to update the node
names and namespaces for your specific solution.
// Takes HTML from a plain text field and inserts it as XHTML into a Rich
Text field.
// HTML could come from another source. It must be valid XML, and this is
not verified.
var textfield = null;
var htmlfield = null;
textfield = XDocument.DOM.getElementsByTagName("myNode:node1")[0];
htmlfield = XDocument.DOM.getElementsByTagName("myNode:node2")[0];
if (textfield.text != "")
{
var xdocFrag = new ActiveXObject("Msxml2.DOMDocument.5.0");
var ns = "xmlns:xhtml=\"
http://www.w3.org/1999/xhtml\"
xmlns:myNode=\"
http://schemas.microsoft.com/office/xdocs/2003/myXSD\""
xdocFrag.async = false;
xdocFrag.validateOnParse = false;
xdocFrag.loadXML("" + textfield.text + "");
var newChild = xdocFrag.documentElement.firstChild;
htmlfield.parentNode.replaceChild(xdocFrag.documentElement.firstChild,
htmlfield);
}
Thanks,
Brian
Li said:
I use rich text control, and I want to set data in the control by code,
sore
line breaks <div></div>
strValue = "<div xmlns=""
http://www.w3.org/1999/xhtml"">" + Value +
"</div>"
Node xml is readonly, How can I set?
Thanks