Parse XML with Namespaces C# -


after posting url, following response:

<?xml version="1.0" encoding="utf-8" ?>  <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">   <soapenv:body>    <soapenv:fault>     <faultcode>123</faultcode>     <faultstring>lorem ipsum</faultstring>     <detail>       <ns1:service xmlns:ns1="http://www.bla.org/">        <messageid>321</messageid>        <text>test text</text>        <variables>19</variables>        <variables>20</variables>       </ns1:service>     </detail>    </soapenv:fault>   </soapenv:body> </soapenv:envelope> 

i want parse , use values

i tried parse xmlstring following class:

public class classxml {      /// <remarks/>     [system.xml.serialization.xmltypeattribute(anonymoustype = true, namespace = "http://schemas.xmlsoap.org/soap/envelope/")]     [system.xml.serialization.xmlrootattribute(namespace = "http://schemas.xmlsoap.org/soap/envelope/", isnullable = false)]     public partial class envelope     {          private envelopebody bodyfield;          /// <remarks/>         public envelopebody body         {                         {                 return this.bodyfield;             }             set             {                 this.bodyfield = value;             }         }     }      /// <remarks/>     [system.xml.serialization.xmltypeattribute(anonymoustype = true, namespace = "http://schemas.xmlsoap.org/soap/envelope/")]     public partial class envelopebody     {          private envelopebodyfault faultfield;          /// <remarks/>         public envelopebodyfault fault         {                         {                 return this.faultfield;             }             set             {                 this.faultfield = value;             }         }     }      /// <remarks/>     [system.xml.serialization.xmltypeattribute(anonymoustype = true, namespace = "http://schemas.xmlsoap.org/soap/envelope/")]     public partial class envelopebodyfault     {          private string faultcodefield;          private string faultstringfield;          private detail detailfield;          /// <remarks/>         [system.xml.serialization.xmlelementattribute(namespace = "")]         public string faultcode         {                         {                 return this.faultcodefield;             }             set             {                 this.faultcodefield = value;             }         }          /// <remarks/>         [system.xml.serialization.xmlelementattribute(namespace = "")]         public string faultstring         {                         {                 return this.faultstringfield;             }             set             {                 this.faultstringfield = value;             }         }          /// <remarks/>         [system.xml.serialization.xmlelementattribute(namespace = "")]         public detail detail         {                         {                 return this.detailfield;             }             set             {                 this.detailfield = value;             }         }     }      /// <remarks/>     [system.xml.serialization.xmltypeattribute(anonymoustype = true)]     [system.xml.serialization.xmlrootattribute(namespace = "", isnullable = false)]     public partial class detail     {          private service servicefield;          /// <remarks/>         [system.xml.serialization.xmlelementattribute(namespace = "http://www.bla.org/")]         public service service         {                         {                 return this.servicefield;             }             set             {                 this.servicefield = value;             }         }     }      /// <remarks/>     [system.xml.serialization.xmltypeattribute(anonymoustype = true, namespace = "http://www.bla.org/")]     [system.xml.serialization.xmlrootattribute(namespace = "http://www.bla.org/", isnullable = false)]     public partial class service     {          private string messageidfield;          private string textfield;          private ulong[] variablesfield;          /// <remarks/>         [system.xml.serialization.xmlelementattribute(namespace = "")]         public string messageid         {                         {                 return this.messageidfield;             }             set             {                 this.messageidfield = value;             }         }          /// <remarks/>         [system.xml.serialization.xmlelementattribute(namespace = "")]         public string text         {                         {                 return this.textfield;             }             set             {                 this.textfield = value;             }         }          /// <remarks/>         [system.xml.serialization.xmlelementattribute("variables", namespace = "")]         public ulong[] variables         {                         {                 return this.variablesfield;             }             set             {                 this.variablesfield = value;             }         }     }     } 

but got error:

exception occured while trying parse xml string <envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'> not expected. 

apparently can't parse xml namespaces parse normal xml

how can parse 1 , values?

any appreciated


Comments