You must Sign In to post a response.
  • Category: XML

    I want to generate an xml file in a specific format

    I wnat to generate an xml file with output as shown below how can i accomplish that

    <?xml version="1.0" encoding="utf-8"?>
    <root>
    <Lgd QdsName="Lgd:BOTTOM_PLANE">
    <Field Dsc="Z1" T="Double">VALUE</Field>
    <Field Dsc="BaseDia" T="Double">value</Field>
    </Lgd>
    <Lgd QdsName="Lgd:TOP_PLANE_TOTAL_WIDTH">
    <Field Dsc="Z2" T="Double">VALUE</Field>
    <Field Dsc="FF_DIA" T="Double">VALUE</Field>
    </Lgd>
    <Lgd QdsName="Lgd:BORE_BOTTOM_SIDE">
    <Field Dsc="Z3" T="Double">Value</Field>
    <Field Dsc="BORE_DIA_1" T="Double">Value</Field>
    </Lgd>
    <Lgd QdsName="Lgd:BORE_TOP_SIDE">
    <Field Dsc="Z4" T="Double">Value</Field>
    <Field Dsc="BORE_DIA_2" T="Double">Value</Field>
    <Field Dsc="$U" T="String"></Field>
    </Lgd>
    <Lgd QdsName="Lgd:RACE_MEASUREMENT">
    <Field Dsc="Z5" T="Double">Value</Field>
    <Field Dsc="CONE_BF_DIA" T="DoublE">Value</Field>
    <Field Dsc="CONE_LENGHT" T="Double">Value</Field>
    <Field Dsc="CONE_ANGLE_IN_DEGREE" T="Double">Value</Field>
    </Lgd>
  • #761228
    Hello,

    Can you elaborate your query in detail in which format you want to and what you want to generate into xml.

    Please describe your query in detail to get faster and reliable answers.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #761232
    There are so many ways to do it
    1. Use a string builder object. add the values to it by itrating through for loop.
    2. if it is an object, there are ways to convert an object to xml
    eg: http://www.codeproject.com/Tips/671853/Data-Object-to-XML-Vice-versa-using-Csharp

    Do Good... Enjoy your life.....

  • #761290
    Hai Mahantesh,
    You can create a DataTable with these fields and insert the data in to the datatable.
    Once all the data is inserted, create a DataSet and add this datatable to the dataset.
    Once you get the dataset, you can use GetXml method which will generate the XML of the data as per the format given.

    DataTable dt = new DataTable();
    dt.Columns.Add("Col1", typeof(string));
    ...
    dt.Rows.Add("add value");

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


Sign In to post your comments