Jump to content

Convert a comma separated list into XML


son

Recommended Posts

I have to convert a comma separated list of products into an xml document (conforming to given xsd specifications). Is there a quick way to do just that? Would take me hours to manually enter 100 products in the XML document.Son

Link to comment
Share on other sites

Nope. There isn't an easy way to do that.About the easiest one I can think of is to use fgetcvs to turn the file into an array, and then trasnalte the array into a "generic" XML (via SimpleXML or better yet, DOM) that may or may not conform to the schema. If it doesn't, create an XSLT file that would convert it into one that would, and use the XSL extension to execute the transformation. Either way, make sure you validate against the schema with DOMDocument::schemaValidate().

Link to comment
Share on other sites

Nope. There isn't an easy way to do that.About the easiest one I can think of is to use fgetcvs to turn the file into an array, and then trasnalte the array into a "generic" XML (via SimpleXML or better yet, DOM) that may or may not conform to the schema. If it doesn't, create an XSLT file that would convert it into one that would, and use the XSL extension to execute the transformation. Either way, make sure you validate against the schema with DOMDocument::schemaValidate().
Thanks for your input;-)Son
Link to comment
Share on other sites

Do you need to do this on the fly, or just one initial time? You could try using MS Excel to create the XML, otherwise, you will need a server side scripting language to do as boen_robot outlined.

Link to comment
Share on other sites

Do you need to do this on the fly, or just one initial time? You could try using MS Excel to create the XML, otherwise, you will need a server side scripting language to do as boen_robot outlined.
I will receive soon a comma separated file (or Excel spreadsheet) with data I have to convert. How would I do this with Excel?Son
Link to comment
Share on other sites

  • 2 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...