Need Help Deserializing XML

The API response looks like this:

<PPMDResults>

<Results>

<drug id="[auto]" updatestatus="[auto]" patientid="PatientID" profilecode="ProfileCode" drugname="DrugName" drugstrength="DrugStrength" doseform="DoseForm" frequency="Frequency" .../>

</Results>

<Error/>

</PPMDResults>

 

I have this to pull and deserialize:

using (var response = request.GetResponse() as HttpWebResponse)

{

      if (response.StatusCode == HttpStatusCode.OK)

     {

           var serializer = new DataContractSerializer(typeof(T));

          responseObject = (T)serializer.ReadObject(response.GetResponseStream());

      }

      else

      {

           //TODO: Handle HttStatusCode != OK

      }

}

return responseObject;

I've tried setting up my DataContract files a number of ways both with just the Medication and MedicationReponse files and layered with a results group and a drug group.  Any way I format it, I'm still getting this error:

ERROR: Exception Type : InvalidExecuteQueryException Message : Adapter Error Error in line 1 position 14. Expecting element 'ArrayOfMedicationResponse' from namespace http://schemas.datacontract.org/2004/07/AmdEhrConnector.Entities'.. Encountered 'Element' with name 'PPMDResults', namespace ''.

 

I'm thinking maybe there's another way to deserialize???  Not sure what the best way to resolve this is.

(2) Answers

Login