[XML Records] XML to RecordList to skip "comments" within "" tags

Forge Component
(44)
Published on 2019-11-25 by Afonso Carvalho
44 votes
Published on 2019-11-25 by Afonso Carvalho

Hi,

I am currently using the XML to RecordList, I added a replace command on the XML text to replace the whole comment to make it work.

Is there a way to skip comments inside "<!-- " and "-->" tags ? if I don't use the replace command, the XMLtoRecordList is taking the comment as  primary node to match the record definition tag, giving an error "The current node (%23comment) does not match the record definition (xxyy)".

Currently, Replace command is working but this may not work if they changed anything inside the comment tags.


Thank you.

-Edwin

Edwin Siruma wrote:

Hi,

I am currently using the XML to RecordList, I added a replace command on the XML text to replace the whole comment to make it work.

Is there a way to skip comments inside "<!-- " and "-->" tags ? if I don't use the replace command, the XMLtoRecordList is taking the comment as  primary node to match the record definition tag, giving an error "The current node (%23comment) does not match the record definition (xxyy)".

Currently, Replace command is working but this may not work if they changed anything inside the comment tags.


Thank you.

-Edwin

Or if there is a way to specify the primary node of the XML so we can easily skip everything before the primary or parent node.


Thanks again!

-Edwin


Hi Edwin,

My apologies for the late reply, but I'll have some time to look at this very soon. I'll see about adding an option to skip comments.

Afonso Carvalho wrote:

Hi Edwin,

My apologies for the late reply, but I'll have some time to look at this very soon. I'll see about adding an option to skip comments.


Thank you, Afonso!

Solution

Hi Edwin,


Me and Afonso fixed the problem, but we cannot attach a new version in forge (we are waiting that OutSystems fixs a forge issue).


In meantime please find in attach the XIF with the bypass of comments.


The Solution:


"

if (ssBypassComments)
                {
                    XmlNodeList allComments = doc.SelectNodes("//comment()");
                    foreach (XmlNode n in allComments)
                    {
                        n.ParentNode.RemoveChild(n);
                    }
                }

"


I hope it helps!


Kindest Regards,

Olga



Solution

Thank you Olga!

This option has been added to the latest version of the extension.

Afonso Carvalho wrote:

This option has been added to the latest version of the extension.

Thank you, Olga and Afonso!



I can only mark one comment as solution, for this I will mark Olga's comment as solution.

It's only fair, she did all the heavy lifting for this!

Thank you for coming back to this, let us know if you have any issues.

Hi Edwin and Afonso, Thank you! :)