Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Not sure if this is the right venue to be asking this but here goes.

A little background.

I'm trying to build an ecommerce app that would allow sellers from other venues--like, amazon and newegg--to import their products using their export/import files.

An example would be a user having an XML feed that looks somewhat like this:

<?xml version="1.0" encoding="UTF-8"?>
<products>
    <product>
        <sku>12345</sku>
        <name>Dell Computer</name>
        <description>This is a very nice Dell computer. Much quality. Very speed. Great wow.</description>
    </product>
    <product>
        <sku>123456</sku>
        <name>Dell Laptop</name>
        <description>This is a Dell laptop. Much quality as well.</description>
    </product>
</products> 

I'd like to be able to map the headers to columns in my database.

ie. sku -> product_sku, name -> product_name, description -> description.

What I'm doing right now is since not all feeds have the same structure, I developed a "mapping tool" that basically just parses the file, takes the headers and shows it in a UI that allows the user to "map" these to the list of my database columns.

The problem I'm encountering now is that since the feeds are not the same, I have a hard time getting that list of headers.

My question is what's a good way to approach this problem? Maybe I'm doing this all wrong.

I'm doing this in nodejs/javascript if that's at all relevant.

share|improve this question

1 Answer 1

Look for product not headers.

Product is the basic unit you are working with. First identify that. In your example, you can see that <product> is the only tag that has siblings of the same name. Although the same would be true for things like <category>, and <colorOption>.

Work with XML paths, not just tag names.

Let a human do the hard bit: get your sellers to pick the "headers" straight from the XML.

Display the XML (maybe as a menu tree) and ask the seller the selected the tag for a Product. Then highlight that fragment and ask the seller to select the tag for ProductName and so on.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.