我有一些数据包含一些字段中的尖括号。
即使正确转义为<:或> (甚至是十六进制代码),在Visual Studio 2005 ASP.Net中,字段数据在第一个尖括号处被截断。 如果我用花括号替换数据,它显示正常。
示例数据(未转义):
<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>
示例数据(转义):
<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>没有做任何棘手的事情,将TreeView绑定到设置了文件名的XMLDataSource,并将绑定指定为DataMember = row和TextField = TopNode。
我没有在网上找到任何东西,但当然搜索“尖括号”只会增加结果的数量,而不是减少它们。
有人看到这样的事吗? 了解变通方法或解决方案? ASP.Net v2.0.50727。
更新:我建议使用的CDATA示例。 没工作。
<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>
I have some data which contains angle brackets in some of the fields.
Even if properly escaped as <: 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	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>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>
最满意答案
如果我对尖括号进行双重编码,它似乎起作用,至少我认为你正在寻找。 所以&lt; 而不是<
我四处寻找这种想法的原因可能会有一个你可以改变的设置。 看起来它来自XmlAttribute类的Value属性,但我没有看到关闭它的方法。
If I double encode the angle brackets, it appears to work, at least how I think you're looking for. So &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.
更多推荐
发布评论