Question

Kawaelon on Thu, 03 Jan 2019 13:45:49


Hello,

I am writing a Word VSTO add-in that loads an XML document on startup and binds it as a Custom XML Part. The idea is that I bind the nodes from Custom XML Part to content controls and allow the user to change the data. After that I would like to extract the data from the Custom XML Part and update it in database. It works as expected but only for plain text control. I use this code

foreach (CustomXMLNode xmlNode in customXMLPart.SelectNodes("//*"))
{
    string text = xmlNode.Text;
}

to iterate through all the nodes of Custom XML Part to find the nodes I am interested in and get their value. The xmlNode.Text works correctly for plain text controls but if I use rich text control instead, the value of xmlNode.Text is replaced by a xml string representing the formatted string. Is there any simple way to extract the unformatted text from it?

Thanks, any help is highly appreciated :)