none
Create new XML File based on existing XML Template File

    Question

  • Hye. I have created a Template File which stored the nodes that needed like below.

    <?xml version="1.0" encoding="utf-8" ?>
    <Template>
      <Columns Name="">
        <ColHeader1></ColHeader1>
        <ColHeader2></ColHeader2>
        <ColHeader3></ColHeader3>
        <Row></Row>
        <Col></Col>
        <Table></Table>
        <TableColName></TableColName>
      </Columns>
      <Reports Name="">
        <Customer></Customer>
        <Worksheet></Worksheet>
        <Step />
        <Criteria />
        <Header1></Header1>
        <Header2></Header2>
        <Header3></Header3>
        <Description />
      </Reports>
    </Template>
    

    Then i needed to loop many times and create new nodes based on template above in a new xml file . For example like below..

    <?xml version="1.0" encoding="utf-8" ?>
    <Template>
      <Columns Name="Sheet1">
        <ColHeader1>Time</ColHeader1>
        <ColHeader2></ColHeader2>
        <ColHeader3></ColHeader3>
        <Row></Row>
        <Col></Col>
        <Table></Table>
        <TableColName></TableColName>
      </Columns>
    Columns Name="Sheet2">
        <ColHeader1>No</ColHeader1>
        <ColHeader2></ColHeader2>
        <ColHeader3></ColHeader3>
        <Row></Row>
        <Col></Col>
        <Table></Table>
        <TableColName></TableColName>
      </Columns>
    
      <Reports Name="Sheet1">
        <Customer>1</Customer>
        <Worksheet>1</Worksheet>
        <Step />
        <Criteria />
        <Header1>Time</Header1>
        <Header2></Header2>
        <Header3></Header3>
        <Description />
      </Reports>
    <Reports Name="Sheet2">
        <Customer>1</Customer>
        <Worksheet>2</Worksheet>
        <Step />
        <Criteria />
        <Header1>No</Header1>
        <Header2></Header2>
        <Header3></Header3>
        <Description />
      </Reports>
    
    </Template>
    
    Is that i have hardcoded and create new node/element everytime i loop? Or is that any way without hard code where where we can use the template xml file and loop through it.
    Monday, August 05, 2013 3:21 AM