更改XML根名称

时间:2015-11-03 10:50:34

标签: c# xml deserialization xml-deserialization

我正在尝试反序列化一个如下所示的XML文件:

<ArrayOf__ptd_student_charges
    xmlns="http://schemas.datacontract.org/2004/07/something.something"
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <__ptd_student_charges>
        ...
    </__ptd_student_charges>
</ArrayOf__ptd_student_charges>

xmlns=..部分在反序列化时给我带来了问题,因此在解析它之前我想将根更改为:

<ArrayOf__ptd_student_charges>
    <__ptd_student_charges>
        ...
    </__ptd_student_charges>
</ArrayOf__ptd_student_charges>

有没有办法做到这一点?我正在将我的XML从web api加载到XDocument中:

HttpWebRequest request = WebRequest.Create(stringUrl) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;

XDocument xdoc = XDocument.Load(response.GetResponseStream());

0 个答案:

没有答案