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
>I use rich text control, and I want to set data in the control by code,
>sore
[quoted text clipped - 6 lines]
>
> Thanks
Li - 27 Sep 2004 20:54 GMT
Thank you for your help
> 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
[quoted text clipped - 38 lines]
> >
> > Thanks
Nicole - 25 Apr 2005 14:53 GMT
hello Brian,
Please I need your help.
Can you please show me sample code on how to do it exactly using
managed code. I'm already getting desperate as I have spent almost
a week trying to figure out how to do it.
Many thanks.
Kind regards