转换XML文档更改编码

时间:2014-02-26 11:49:45

标签: c# xml xslt encoding utf-8

我有以下代码:

XslCompiledTransform transform = new XslCompiledTransform();
XsltArgumentList arguments = new XsltArgumentList();

string txId = SPOZUS_T2S_COMMON.Spozus.GetUniqueInputId;
arguments.AddParam("Id", string.Empty, txId);

foreach (KeyValuePair<string, string> kvp in args)
{
    arguments.AddParam(kvp.Key, string.Empty, kvp.Value);
}
using (StringReader sr = new StringReader(xslt))
{
    using (XmlReader reader = XmlReader.Create(sr))
    {
            transform.Load(reader); // load transformation
    }
}

XDocument inDoc = new XDocument(_ecpIn.Message); // input document
XDocument outDoc = new XDocument(); // output document

using (XmlReader reader = inDoc.CreateReader())
{
    XmlWriter XWriter = outDoc.CreateWriter();
    using (XmlWriter writer = XmlWriter.Create(XWriter, transform.OutputSettings))
    {
        transform.Transform(reader, arguments, writer); // do the transformation
    }
}

我在utf-8中有源文件inDoc,我需要在文本值元素的值中替换强调的字符,并删除那些与此模式不匹配的字符([0-9a-zA-Z- \? :()。,'+]([0-9a-zA-Z - \?:()。,'+] (/ [0-9a-zA-Z- \?:()。,' +])?))。 有什么想法吗?

0 个答案:

没有答案