An error occurred while parsing EntityName. Line1, position 581

Recently I ran into this error for couple of times.


Both the times this issue was due to the ‘&’ character in the address field of the XML message being processed in BizTalk.

‘&’ is basically an invalid XML character along with following and should be replaced / encoded before using them in XML.


There is better / nicer way of achieving the same outcome by using SecurityElement.Escape method under System.Security namespace in .NET 4.5 and above.


Here Escape method will replace “&” with “&”. This method basically replaces invalid XML characters in a string with their valid XML equivalent.

So its always better to use this method while processing the address or other fields from XML message where the content of the field may contain invalid XML characters.

 Related links:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s