从字符串中删除转义序列'\'将其转换为XmlDocument [英] Remove the escape sequence '\' from string to convert it to XmlDocument
本文介绍了从字符串中删除转义序列'\'将其转换为XmlDocument的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?xml version = \1.0\ encoding = \utf-8\?>
<引用xmlns:xsi = \http://www.w3.org/2001/XMLSchema-instance\xmlns:xsd = \http://www.w3.org/2001/XMLSchema\xmlns = \http://tempuri.org/\>
< price> 19656< / price> ;
< / Quote>
解决方案
使用 Regex.Unscape 方法。
String unescapedString = Regex.Unescape(textString);
I have a web service which returns a struct object, so I get the response as the following XML string. Now I need to load it into XmlDocument object but how do I get rid of the escape sequences in the string. The '\' with every '"' is causing error.
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<Quote xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://tempuri.org/\">
<price>19656</price>
</Quote>
解决方案
Use Regex.Unescape method.
String unescapedString = Regex.Unescape(textString);
这篇关于从字符串中删除转义序列'\'将其转换为XmlDocument的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文