Jump to content
Sign in to follow this  
son

Convert a comma separated list into XML

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

Share this post


Link to post
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().

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...