简体   繁体   English

将xml保存到TFS字段时出现问题

[英]Problem saving xml to a TFS field

I'm working with Linq to xml, and I save my xml in a standars text field in one ordanary SQL database. 我正在使用Linq to xml,并将xml保存在一个普通SQL数据库的standars文本字段中。

Now to my problem: I want to be able to sync the things I save in my SQL text field with a field in TFS. 现在要解决我的问题:我希望能够将保存在SQL文本字段中的内容与TFS中的字段同步。 The problem is when I save the xml which is a string, my TFS field removes all the xml tags, and when I query my tfs field again I get back the text in my xml without the xml tags, but with the <body> at the begining and </body> in the end? 问题是当我保存字符串形式的xml时,我的TFS字段删除了所有的xml标记,并且当我再次查询tfs字段时,我取回了xml中没有xml标记的文本,但是使用了<body>开头和结尾是</body>

I'm saving the text to the field in code using this: 我使用以下命令将文本保存到代码中的字段中:

workItem["Customer.CustomerXMLTalk"] = newXMLTalk.ToStringWithDeclaration();

What do I have to change with my TFS field inorder to be able to save the xml as a string without loosing my tags. 我必须对TFS字段进行哪些更改,以便能够将xml保存为字符串而不丢失标签。

Thanks! 谢谢!

Try HTML Encoding the string before you save it. 在保存字符串之前,请尝试对字符串进行HTML编码。

workItem["Customer.CustomerXMLTalk"] = 
      System.Web.HttpUtility.HtmlEncode(newXMLTalk.ToStringWithDeclaration());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM