public static XmlNode CreateCustomNode(WordDocument doc, string elementName, int id) { XmlNode customNode = doc.CreateNode(XmlNodeType.Element, "w:customXml", Definitions.WORD_PROCESSING_ML); XmlAttribute attr = doc.CreateAttribute("w:element", Definitions.WORD_PROCESSING_ML); attr.Value = elementName; customNode.Attributes.Append(attr); attr = doc.CreateAttribute("w:object_id", Definitions.WORD_PROCESSING_ML); attr.Value = id.ToString(); customNode.Attributes.Append(attr); return customNode; }
public static XmlNode CreateTextChildNode(WordDocument doc, string text) { XmlElement tagParagraph = doc.CreateElement("w:p", Definitions.WORD_PROCESSING_ML); XmlElement tagRun = doc.CreateElement("w:r", Definitions.WORD_PROCESSING_ML); tagParagraph.AppendChild(tagRun); XmlElement tagText = doc.CreateElement("w:t", Definitions.WORD_PROCESSING_ML); tagRun.AppendChild(tagText); XmlNode nodeText = doc.CreateNode(XmlNodeType.Text, "w:t", Definitions.WORD_PROCESSING_ML); nodeText.Value = text; tagText.AppendChild(nodeText); return tagParagraph; }