105
Views
1
Comments
[XML] Problem getting some characters
Question

Hello guys,

I'm using the action "XmlToRecordList", with the header: <?xml version="1.0" encoding="UTF-8"?>.

I'm getting all the information that I want, including the characters: &, ' and ". The problem come when I insert < and >. If I use ">" alone, there is no problem. But if I try to insert "<", I get an error. The way I found to avoid this kind of problems, is replacing them, for example: 

Replace(XML,"&","& + amp;")

but with "<" I can't do it because I have a lot of tags as you understand.

So, I need to protect from errors, when the file has "<".

Anyone can help me?

2022-06-10 12-50-39
Allen Helton

It sounds like you're running into issues escaping special characters in your xml. There is a good stack overflow article here on how to escape xml characters. 

For your use case, you'll want to manipulate the xml prior to using the XmlToRecordList action. Taken from this article, you'll want to:

Add the following Dependencies to your Module:

  • BinaryDataToText from the BinaryData Extension
  • XmlDocument_Load from the Xml Extension
  • XmlDocument_SelectNodes from the Xml Extension
  • XmlElement_GetInnerText from the Xml Extension
  • XmlElement_SelectSingleNode from the Xml Extension
  • XmlNodeList_Count from the Xml Extension
  • XmlNodeList_Item from the Xml Extension

You would then iterate through each item escaping the content with one of the methods from the stack overflow link.

After escaping all the values, you then should be able to put it all back into your variable to feed it into the XmlToRecordList action.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.