locked
XML Format RRS feed

  • Question

  • Hi All,

    I want to format my results in the following format in .aspx page.

    <Result><record>{data}</record><record>{data}</record>.........</Result> (using XDocument).

    I have written the following code

    foreach (DynamicEntity CurrentRecord in RetrieveResponse.BusinessEntityCollection.BusinessEntities)
                {
                    HandlerResponse.Root.Add(new XElement("record"));
                    HandlerResponse.Root.Element("record").Value = ((KeyProperty)CurrentRecord.Properties[0]).Value.Value.ToString();
                }

    It wont work for me. It will always updates the first node only. plz help me in this.

    Regards,

    Rajsekhar.


    rajsekhar

    Monday, April 9, 2012 6:24 PM

Answers

  • You haven't supplied enough code for me to be 100% certain what you're doing, but try:

    XElement record = new XElement("record");
    record.Value = ((KeyProperty)CurrentRecord.Properties[0]).Value.Value.ToString();
    
    HandlerResponse.Root.Add(record);
    


    --pogo (pat) @ pogo69.wordpress.com

    Monday, April 9, 2012 7:19 PM

All replies

  • You haven't supplied enough code for me to be 100% certain what you're doing, but try:

    XElement record = new XElement("record");
    record.Value = ((KeyProperty)CurrentRecord.Properties[0]).Value.Value.ToString();
    
    HandlerResponse.Root.Add(record);
    


    --pogo (pat) @ pogo69.wordpress.com

    Monday, April 9, 2012 7:19 PM
  • Just a suggestion.  Add a counter inside the loop to make sure that the program runs through all the records.  At the end display the counter in an alert box.  Sound like silly Micky Mouse logic, but we often take the small things for granted and scratch our heads for hours trieng to get to the bottom of big issues...

    Please vote if you find my post useful. Add me on @ Skype christo.skype1

    Tuesday, April 10, 2012 7:55 AM