Open JoshC94 opened 6 years ago
Would it be feasible to build up the XML using the XML APIs but then before sending the document treat it as a regular string and do the final character replacement?
XmlDocument.WriteTo(outStream);
outStream.WriteText(text);
text.Replace('"', '"');
Hi,
thanks for your Answer. I thought of solving it in a similar way, but I realized I can't just replace every quote as doing so would destroy the XML structure (because attribute delimiters would also be replaced). It would therefore be necessary to find a context sensitive way of post processing, to only replace characters that are part of the actual content of attributes or text nodes.
Would it be possible to include XMLEntityReference (or something similar) into AL if there are no better options?
Josh
Would it be feasible to build up the XML using the XML APIs but then before sending the document treat it as a regular string and do the final character replacement?
XmlDocument.WriteTo(outStream); outStream.WriteText(text); text.Replace('"', '"');
How to access each XML node one by one in AL? Please provide code if you have for reading nodes and their data one by one...
My XML Content [XmlText] snippet:
Thanks in Advance!
Hi,
I am currently trying to generate some XML using AL's XML API. While the generation itself works just fine, I am encountering an issue when it comes to format specific requirements.
The receiver of the XML file forces me to replace the chars
'
,"
,<
,>
,&
with their respective XML entities'
,"
,<
,>
,&
, regardless of their location in the document (Attribute or Textnode value). However XmlElement.SetAttribute() and XmlText.Create() only replace some of those chars in order to keep the document wellformed.Attributes:
"
-->"
<
--><
>
-->>
&
-->&
Textnodes:
<
--><
>
-->>
&
-->&
Example
AL Code:
Actual output:
Required output:
So
'
('
) is never replaced, while " ("
) is only replaced when used in an attribute. Although this makes perfect sense, I need to replace all of the mentioned chars as per the requirements.I tried to manually replace the chars with their respective XML entities before adding the text to an attribute / textnode, but, for example, instead of
'
i got&apos;
, because Ampersands are replaced automatically when adding the preprocessed text. In the past (using C/AL and DotNet) we solved this by usingXmlEntityReference
, but as there currently is no such class in AL, I can't think of a possible solution for my problem.Can anyone think of a solution for this? Or, if there currently is no way to accomplish what i am trying to do, would it be possible to add
XmlEntityReference
to AL's XML API?Thanks in advance.
Kind Regards, Josh