Skip to content

Instantly share code, notes, and snippets.

@gregawoods
Last active November 1, 2022 12:22
Show Gist options
  • Save gregawoods/91152da26231f4c2ef2fd10297f8e0ac to your computer and use it in GitHub Desktop.
Save gregawoods/91152da26231f4c2ef2fd10297f8e0ac to your computer and use it in GitHub Desktop.
Recursively download XSD documents for use with Amazon MWS.

Recursively download XSD documents for use with Amazon MWS. These can be used to validate XML documents before posting them to the Amazon Feeds API.

You could schedule this to run occasionally via cron in order to keep your XSD files up to date.

See also:

Usage

Files are downloaded to lib/xsd. Modify download_xsd_file to store somewhere else.

rake amazon:xsd
require 'nokogiri'
namespace :amazon do
desc 'Download XSD files recursively'
task xsd: :environment do
dest = download_xsd_file(
'amzn-envelope.xsd',
'https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_1_9/'
)
# Validate schema
Nokogiri::XML::Schema(File.open(dest))
puts 'Done!'
end
def download_xsd_file(file_name, base_url, downloads: [])
return if downloads.include?(file_name)
puts "- downloading #{file_name}..."
downloads << file_name
destination = Rails.root.join('lib', 'xsd', file_name)
File.open(destination, 'w') do |f|
IO.copy_stream(open(base_url + file_name), f)
end
raw_xml = Nokogiri::XML(File.open(destination))
raw_xml.xpath('//xsd:include').each do |tag|
file_name = tag.attribute('schemaLocation').value
download_xsd_file(file_name, base_url, downloads: downloads)
end
destination
end
end
@MST1122
Copy link

MST1122 commented Mar 30, 2021

@gregawoods, I need some help related to Amazon XSD's, please send me your Skype Id, email, or anything where I can contact you.

@gregawoods
Copy link
Author

@MST1122 Hi there! Is there something specific I can help with?

I haven't really touched Amazon MWS in a few years so my knowledge may be rusty.

@MST1122
Copy link

MST1122 commented Mar 31, 2021

I am given a task to-do listing on Amazon, by using the Amazon Feed option. I have spent too much time trying to generating dynamic HTML forms from given XSD's and then generate XML from submitted data.

But un-successful. The only option I can see now is to generate manually HTML form and but still, I get stuck again at Category-based HTML form, what should I do for that?

I wanted to know if you can guide me and help me with this. or connect me with someone who can help me?

I am stuck on this listing thing for almost the last 6 weeks.

@gregawoods
Copy link
Author

I see. Unfortunately that sounds outside the scope of what I can really help with here. You might have better luck posting somewhere like stackoverflow, and including samples of the work you've done so far, pertinent error messages, and so on. Best of luck!

@iamsr
Copy link

iamsr commented Jun 29, 2021

I am given a task to-do listing on Amazon, by using the Amazon Feed option. I have spent too much time trying to generating dynamic HTML forms from given XSD's and then generate XML from submitted data.

But un-successful. The only option I can see now is to generate manually HTML form and but still, I get stuck again at Category-based HTML form, what should I do for that?

I wanted to know if you can guide me and help me with this. or connect me with someone who can help me?

I am stuck on this listing thing for almost the last 6 weeks.

did you got some success in it?

  • [ ]

@MST1122
Copy link

MST1122 commented Jun 29, 2021

@iamsr
Not really. still stuck with the same problem. No progress till now. You have any idea, what can be done?

@iamsr
Copy link

iamsr commented Jun 30, 2021

@MST1122 idk they have release the new better API for product type and listing but it's very limited like only around 30 product type are there in the list right now/ They will update it later on but idk when

@MST1122
Copy link

MST1122 commented Jun 30, 2021

@iamsr can you share the link for the new API for product type and listing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment