diff --git a/word/Editor/custom-xml/custom-xml.js b/word/Editor/custom-xml/custom-xml.js index adadbeea6a..2bd517edaa 100644 --- a/word/Editor/custom-xml/custom-xml.js +++ b/word/Editor/custom-xml/custom-xml.js @@ -89,9 +89,21 @@ }; CustomXml.prototype.addContentByXMLString = function (strCustomXml) { + let nXmlHeaderStart = strCustomXml.indexOf('', nXmlHeaderStart); + let strXmlHeader = null; + if (nXmlHeaderStart !== -1 && nXmlHeaderEnd !== -1) + { + strXmlHeader = strCustomXml.substring(nXmlHeaderStart, nXmlHeaderEnd + "?>".length); + strCustomXml = strCustomXml.substring(nXmlHeaderEnd + '?>'.length, strCustomXml.length); + } + let oStax = new StaxParser(strCustomXml), rootContent = new CustomXmlContent(null); + if (strXmlHeader !== null) + rootContent.xmlQuestionHeader = strXmlHeader; + while (oStax.Read()) { switch (oStax.GetEventType()) { @@ -130,6 +142,7 @@ this.content = []; this.attribute = {}; this.textContent = ""; + this.xmlQuestionHeader = null; this.addAttribute = function (name, value) { @@ -178,7 +191,9 @@ if (!content.name) { - writer.WriteXmlString("\n"); + if (content.xmlQuestionHeader !== null) + writer.WriteXmlString(content.xmlQuestionHeader + "\n"); + current = content.content[0]; } else