XML数据转换为C#中的字符串 [英] xml data to string in C#

查看:104
本文介绍了XML数据转换为C#中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用xslt将原始xml转换为另一个xml文件.
代替将其存储为文件,我可以将xml数据存储在字符串中

i convereted a raw xml into another xml file using xslt.
instead of storing it as a file can i store the xml data in a string

推荐答案

您可以将其读取为字符串:
You can read it in to a string:
using System.IO;

/* ... */

String xmlText = File.ReadAllText(@"path\to\your\file.xml");


XML数据已经是字符串.如果应为不同的字符串,则应指定所有详细信息.该请求没有任何意义.

—SA
XML data is already a string. If it should be a different string, you should specify all the detail. The request makes no sense.

—SA


显然,您不是唯一想这样做的人.
我在这里找到一篇文章来解释这个主题:
http://discuss.joelonsoftware.com/default.asp?dotnet.12.310872.6 [ ^ ]
Apparently you are not the only one that ever wanted to do this.
I found an article explaining the topic here :
http://discuss.joelonsoftware.com/default.asp?dotnet.12.310872.6[^]


这篇关于XML数据转换为C#中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆