"S.Y.M. Wong-A-Ton" wrote:
> The contents of a rich text box is stored as XHTML. To preserve line breaks,
> which are essentially achieved through the use of <DIV> elements within the
> contents of the rich text box, you would have to copy the entire XML content
> of the node pertaining to the first rich text box, create a new node, set the
> XML content of the newly created node to the content copied from the first
> rich text box, and then replace the node pertaining to the second rich text
> box with the new node using replaceChild().
> S.Y.M. Wong-A-Ton
> "Andrew" wrote:
> > Does anyone know of a way to transfer text from one rich text box to another
> > and being able to keep the return lines in there.
> > Thanks,
> > Andrew
I've tried to do something like this
I do understand why that won't work but I'm still new to XML.
and If I do this ...
Then it copies the text over without keeping the line breaks.
Thanks for any help!
string RTF-a = thisXDocument.DOM.selectSingleNode("/my:myFields/my:a").xml;
you will see a bunch of <DIV> elements contained in <my:a>. What worked for
me was to build a loop over the childNodes contained in <my:a> and then
compose a string from these childNodes. I haven't yet found a "nicer" way to
copy the XML inside a node. You can do a check on
before starting the loop over the childNodes. Then you must retrieve the
nodeName, nodeType, and namespaceURI of <my:b> (these are all properties of a
node) and use them to create the new XML for this node as a string that
contains the inner XML copied from <my:a>.
You can then use thisXDocument.CreateDOM() to instantiate a new XML node
(we'll call this newChild), and then newChild.loadXML() to load the XML
string for the new <my:b> into this new XML node.
Then you retrieve the old <my:b> (let's call it oldChild) and with a
replaceChild(), you replace it with the new XML node for <my:b> like this
Hope this helps. If you're still having difficulty getting this to work,
I'll convert your scenario to a "recipe" (=solution) and post it on my
website this weekend.
Oh you mentioned that you have a website, may I have the web address to
check it out?
Thank you again!!
I have the same problem, but i have one Rich Text field with tables, text in
bold, text in different size, etc...and i would like to copy the values from
one field to another field,
do you think this code could be used also to pass that kind of information?
And yes both fields are rich text. I'm trying to use your suggestion about
how to transfer text from one field to another, but i'm having problems when
i want to do the replace child instruction. My field "B" does not have any
How can i create a new child for my field "B" where i want to pass the rich
text value from my field "A" ?, i mean i can do a loop for my field "A" and
get the XML data, but i don't understand how to pass every XML data for each
child of my field "A" to my field "B".
IXMLDOMNode node1 =
if (node1 != null)
IXMLDOMDocument newchild = doc.CreateDOM();
childtext = node1.xml.ToString();
string newtxtofnode2= childtext.Replace("NameOfChild_1",
And it works !!
Thanks for your help !