locked
Is it possible to create a HealthRecordItem in c# from xml? RRS feed

  • Question

  • I don't want to have to generate the entire xml that includes the keys and everything else.

    I would like to do something like:

    string
     xml = <weight>
    <value>
    <kg>60</kg>
    <display units=\"lb\">132</display>
    </value>
    </weight>";
    HealthRecordItem item = new HealthRecordItem(xml);
    accessor.NewItem(item);

    Sorry about the spacing, I can't fix it.

    Thanks,

    KK

    Tuesday, August 24, 2010 6:12 AM

Answers

  • Hello ,

    Yes, It is possible to create a HealthRecordItem from XML. You can use the below sample code to achieve this functionality.

    HealthRecordAccessor accessor =
                new HealthRecordAccessor(offlineConn, recordGuid);

            //Add Height entry

            string heightXml = @"<height><when><date><y>2020</y><m>08</m><d>24</d></date><time><h>14</h><m>10</m><s>15</s></time></when><value><m>1.98836235003004</m></value></height>";

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(heightXml);

            HealthRecordItem height = new HealthRecordItem(Height.TypeId, doc);

            accessor.NewItem(height);

    Regards,
    Madan Kamuju
    • Proposed as answer by Madan kamuju Tuesday, August 24, 2010 10:08 AM
    • Marked as answer by Aneesh D Wednesday, November 24, 2010 9:13 PM
    Tuesday, August 24, 2010 10:08 AM