0

I am trying to deserialize an XML file that looks like this:

<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>

The xmlns=.. part is giving me problems when deserializing, so before parsing it I would like to change the root to:

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

Is there any way to do this? I am loading my XML from a web api into an XDocument:

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

XDocument xdoc = XDocument.Load(response.GetResponseStream());
kkyr
  • 3,785
  • 3
  • 29
  • 59
  • It's just normal, regular XML namespace - nothing magic about it. Instead of mangling the XML before deserializing, you should learn **how to support** XML namespaces when you're deserializing - it's pretty easy, too! Show us the deserializing code, and we can help you – marc_s Nov 03 '15 at 11:10
  • 1
    Thank you for your comment @marc_s. I didn't know you could support XML namespaces. You can find my full code here: http://stackoverflow.com/questions/33495857/deserializing-an-xml-array-from-a-web-api. I'm sure the answer is simple, I'm just not familiar with it at all – kkyr Nov 03 '15 at 11:13
  • See my response to your original question – marc_s Nov 03 '15 at 11:19

0 Answers0