Welcome Guest Search | Active Topics | Members | Log In | Register

Lesson Learned: XML In a Object Property Options
topex
Posted: Friday, January 01, 2010 8:10:16 PM
Rank: Member

Joined: 1/1/2010
Posts: 3
Points: 9
If you are storing any information in a CreateClickAction Property, make sure to special encode your data first before saving. It does not like "<, >, and &" to be in the property.

Example:

Code:
EntreeClickActionObject click = output.CreateClickAction();
click["message"] = "Hi, I & Julie like you <:->";


What i did to get around this is I created special methods to encode and decode this information. I reason I created a special one is the use of XMLEncode, HTMLEncode, or URLEncode, resulted in the same error.

Here are the two methods I created.

Code:
public string SpecialEncode(string strToEncode)
{
return strToEncode.Replace("&", "#AMP#").Replace("<", "#LT#").Replace(">", "#GT#");
}

public string SpecialDecode(string strToDecode)
{
return strToDecode.Replace("#AMP#", "&").Replace("#LT#", "<").Replace("#GT#", ">");
}


In the end my message is encoded first.
Code:
click["message"] = SpecialEncode("Hi, I & Julie like you <:->");

Then when I display it I make sure to decode it first.
Code:
output.ErrorString = SpecialDecode(EntreeScope.Properties["message"]);
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.