Get node value of invalid format of XML and SOAP responses in C# MVC WebAPI.



  • Here is the solution to get the node value even the format of response is not valid. In some situation from third party vendor when we get the response, it is not always in proper format. When we try to de serialize or parse it, it always throw error that input string is not in valid format. We don’t get response in actual XML or Soap format.
  • In every xml and soap response there are 2 different part – <header>,  <body>.
  •   In some situation we only receive <body> , not <header> inside which mostly definition or format of response is defined.  

  • We get the response in below format. 



  • In which element tag value will be in below format.











  • Using above code we can get the value of <ElementName> tag: "ABC14453535441143"

Comments

Post a Comment