Hatchomatic

Share this post

Simple XML template

www.hatchomatic.com

Discover more from Hatchomatic

Musings on life, travel, pets, woodworking... whatever.
Continue reading
Sign in

Simple XML template

Joshua Hatch
Feb 18, 2009
Share this post

Simple XML template

www.hatchomatic.com
Share

Quite often, I need to turn a tab-delimited text file or Excel spreadsheet into an XML document. The easiest way to do that is with a spreadsheet that uses a formulas to build the XML into one column. Here is such a file (actually, this is a collection of .xls, .xlsx, and Numbers '08 and Numbers '09 files). What you'll see is a seven-column spreadsheet with a header row. The seventh colum is simply a formula concatenating the other columns. That formula reads as follows:

="<a "&$A$1&"="""&A2&""" "&$B$1&"="""&B2&""" "&$C$1&"="""&C2&""" "&$D$1&"="""&D2&""" "&$E$1&"="""&E2&""" "&$F$1&"="""&F2&"""/>"

What that's saying is, the cell is equal to the literal text <a , followed by the absolute reference to cell A1, followed by the literal text =" followed by the relative reference to cell A2, and so on. The nice thing about this is that you can quickly and easily change the headers in the spreadsheet, and the XML will change accordingly. Likewise, you can change the values. And, it's relatively simple to add and delete attributes (columns) to grow or shrink the file as needed. Enjoy!

Share this post

Simple XML template

www.hatchomatic.com
Share
Previous
Next
Comments
Top
New
Community

No posts

Ready for more?

© 2023 Joshua Hatch
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing