I'm trying to replace a text element placeholder with an image in an openXML docx.
I've found a tutorial here which seems to do what I need, but I'm not quite following what he does to insert the image.
Basically, I have an XML 'image template' stored in a string. I can store my image to media folder and insert the image ID into the XML string:
string imageNode
= _xml.Replace("##imageId##", documentMainPart.GetIdOfPart(newImage));
so now I have the correct XML as a string which I need to insert into the document.
I can find my placeholder text node which I want to replace with the new image XML
var placeholder = documentMainPart.Document.Body
.Descendants<DocumentFormat.OpenXml.Wordprocessing.Text>()
.Where(t => t.Text.Contains("##imagePlaceholder##")).First();
But this is where I get stuck. I can't see how to do a replace/insert which will take an XML string. I've managed to get my XML output as text in the document, but I beed to somehow convert it into an XML element.