Alex
Alex

Reputation: 83

Convert Excel spreadsheet to XML with attributes

I have an Excel spreadsheet that is full of part numbers and components which belong to that part number. I'd like to convert this to XML for a program I'm redesigning. Below is how the columns in the Excel file are laid out:

Product Part number | PCA | Reference Designator | Item Number | Location

I'd like to format the XML file to show like the following:

<Product_Part_Number>
  <PCA_1>
    <Part>
      <RefDes>Z001</RefDes>
      <ItemNum>1234567</ItemNum>
      <Location>Bin 1</Location>
    </Part>
  </PCA_1>
  <PCA_2>
    <Part>
      <RefDes>R001</RefDes>
      <ItemNum>987654</ItemNum>
      <Location>Bin 30</Location>
    </Part>
  </PCA_2>
</Product_Part_Number>

Is there a way I can read in a column at a time, add the PCA level, then the RefDes level, etc? I'm thinking it would require a couple of loops but was curious if someone has already done this before.

Upvotes: 0

Views: 264

Answers (1)

Marco Aguilar
Marco Aguilar

Reputation: 90

You can export the xml file to CSV format, then it would be easy to process in C# code.

Upvotes: 1

Related Questions