I'm using Actionscript's XML class to read and modify an Word OpenXML document. For some reason, after I'm done modifying the XML, converting it back to a string removes whitespaces from text nodes. Actually, that's not really true, because the unmodified XML document also doesn't have those spaces, but they still show up in the word document. In fact, if all I do with the document's content is parse it with the XML parser and then convert it back to a string, the only difference between the untouched XML and the one that went through the parser is that the xml:
namespace prefix is stripped out from the space
attribute of the w:t
nodes.
Sample of the Untouched XML:
<w:p w:rsidR="0012761D" w:rsidRPr="004F0FA6" w:rsidRDefault="0012761D" w:rsidP="004F0FA6"> <w:pPr> <w:rPr> <w:rFonts w:ascii="Gotham Book" w:hAnsi="Gotham Book"/> <w:b w:val="0"/> <w:sz w:val="20"/> <w:szCs w:val="20"/> </w:rPr> </w:pPr> <w:r w:rsidRPr="004F0FA6"> <w:rPr> <w:rFonts w:ascii="Gotham Book" w:hAnsi="Gotham Book"/> <w:b w:val="0"/> <w:sz w:val="20"/> <w:szCs w:val="20"/> </w:rPr> <w:t xml:space="preserve">Distance</w:t> </w:r> <w:r w:rsidR="004F0FA6"> <w:rPr> <w:rFonts w:ascii="Gotham Book" w:hAnsi="Gotham Book"/> <w:b w:val="0"/> <w:sz w:val="20"/> <w:szCs w:val="20"/> </w:rPr> <w:t>at</w:t> </w:r> <w:r w:rsidRPr="004F0FA6"> <w:rPr> <w:rFonts w:ascii="Gotham Book" w:hAnsi="Gotham Book"/> <w:b w:val="0"/> <w:sz w:val="20"/> <w:szCs w:val="20"/> </w:rPr> <w:t xml:space="preserve">SL, ISA, MTOW</w:t> </w:r>
Sample from the XML that went through Actionscript's parser:
<w:p w:rsidR="0012761D" w:rsidRPr="004F0FA6" w:rsidRDefault="0012761D" w:rsidP="004F0FA6"> <w:pPr> <w:rPr> <w:rFonts w:ascii="Gotham Book" w:hAnsi="Gotham Book"/> <w:b w:val="0"/> <w:sz w:val="20"/> <w:szCs w:val="20"/> </w:rPr> </w:pPr> <w:r w:rsidRPr="004F0FA6"> <w:rPr> <w:rFonts w:ascii="Gotham Book" w:hAnsi="Gotham Book"/> <w:b w:val="0"/> <w:sz w:val="20"/> <w:szCs w:val="20"/> </w:rPr> <w:t space="preserve">Distance</w:t> </w:r> <w:r w:rsidR="004F0FA6"> <w:rPr> <w:rFonts w:ascii="Gotham Book" w:hAnsi="Gotham Book"/> <w:b w:val="0"/> <w:sz w:val="20"/> <w:szCs w:val="20"/> </w:rPr> <w:t>at</w:t> </w:r> <w:r w:rsidRPr="004F0FA6"> <w:rPr> <w:rFonts w:ascii="Gotham Book" w:hAnsi="Gotham Book"/> <w:b w:val="0"/> <w:sz w:val="20"/> <w:szCs w:val="20"/> </w:rPr> <w:t space="preserve">SL, ISA, MTOW</w:t> </w:r>
As you can see, the only difference is between <w:t xml:space="preserve">Distance</w:t>
and <w:t space="preserve">Distance</w:t>
. So I tried manually adding the xml:
prefix to the space attributes, but that doesn't have any effect.
I also tried to set the prettyPrinting
property of the XML class to false
but it somehow corrupts the document.
So what can I do?
Thanks.
No comments:
Post a Comment