Setup
Here's my mathML expression:
mathML = ExportString[1/2, "MathML"]
"<math xmlns='http://www.w3.org/1998/Math/MathML'> <mfrac> <mn>1</mn> <mn>2</mn> </mfrac> </math>"
and an XMLElement
:
xml = XMLElement["tag", {}, {"data", mathML}]
Task and the problem
which I'd like to Export(String)
without manipulating mathMLcontents but it converts some symbols:
ExportString[xml, "XML"]
"<tag>data<math \
xmlns='http://www.w3.org/1998/Math/MathML'>
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</math></tag>"
Expected result:
while I'd like to get:
"<tag>data<math xmlns='http://www.w3.org/1998/Math/MathML'>
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</math></tag>"
Solution(?)
I can get this with
ExportString[xml, "XML", "Entities" -> {"<" -> "<", ">" -> ">", "'" ->"'"}]
but is this the right approach? If not, can I restrict this to only MathML expressions somehow?
A problem with solution:
The problem is that if those symbols are somewhere outside MathML expression, the resulting XML document will have incorrect structure:
ExportString[
XMLElement["tag", {}, {"1 > 2"}],
"XML",
"Entities" -> {"<" -> "<", ">" -> ">", "'" -> "'"}
]
"<tag>1 > 2</tag>"
I suppose it is not acceptable. I'm not sure though.