ASP.NET Treeview control failing to handle angle brackets in data

I have some data which contains angle brackets in some of the fields.

Even if properly escaped as &lt: or > (or even the hex codes), in Visual Studio 2005 ASP.Net, the field data is being truncated at the first angle bracket. If I replace the data with curly braces, it displayes fine.

Example Data (unescaped):

<ITReview><row TopNode="REQ 123456 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/><row TopNode="REQ 456789 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/></ITReview><ITReview><row TopNode="REQ 123456 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/><row TopNode="REQ 456789 TT Description <Date sent to app dev> <Priority> <SubTask Status>"/></ITReview>

Example Data (escaped):

<ITReview>
<row TopNode="REQ 123456&#x09;TT Description&#x09;&lt;Date sent to app dev&gt;&#x09;&lt;Priority&gt;&#x09;&lt;SubTask Status&gt;"/>
<row TopNode="REQ 456789&#x09;TT Description&#x09;&lt;Date sent to app dev&gt;&#x09;&lt;Priority&gt;&#x09;&lt;SubTask Status&gt;"/>
</ITReview>

Not doing anything tricky, binding the TreeView to an XMLDataSource with the file name set, and specifying the binding as DataMember=row and TextField=TopNode.

I didn't find anything online, but of course searching for "angle bracket" just increases the number of results, not decreases them.

Anyone see anything like this? Know of a workaround or solution? ASP.Net v2.0.50727.

Update: example of the CDATA I used, as suggested. Didn't work.

<ITReview> <TopNode> <MainData> <![CDATA[REQ 123456 TT Description <Date sent to app dev> <Priority> <SubTask Status>]]> </MainData> </TopNode> <TopNode> <MainData> <![CDATA[REQ 456789 TT Description <Date sent to app dev> <Priority> <SubTask Status>]]> </MainData> </TopNode> </ITReview>

Answers


If I double encode the angle brackets, it appears to work, at least how I think you're looking for. So &amp;lt; instead of <

I poked around looking for the cause of this thinking there might be a setting you could change. It looks like it's coming from the Value property of the XmlAttribute class, but I don't see a way to turn it off.


Try writing it out within the context of an HTMLEncode()


Can you modify the source XML, such that instead of having your data in the TopNode="" attribute, you have <row><TopNode><![CDATA[long string]]></TopNode></row>?


Need Your Help

Determine Total Count Of Items Returned By SPQuery

sharepoint sharepoint-2010 caml

I'm running a number of CAML queries against a large list in SharePoint 2010, and displaying the results in a gridview to the end user. I wish to page through the results returned by the query to i...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.