Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xml_dict = {'g:price' : item.Price, #key, 'g:price' is a string, item.Price is a attribute name or whatever
- 'title': item.SKU,
- 'description' : item.Description} #etc etc
- xml_dict.keys() #is a list of all the keys in the dict, so 'gprice' and 'title' and 'desc'
- if reader.Name in xml_dict.keys(): #if the name matches any of the keys in the dict
- xml_dict[reader.Name] = reader.ReadElemContAsStr() # set the value of the key to the element in the XML
- # line above turns into: item.SKU = reader.ReadElementContentAsString()
- # example: reader.Name = 'title' so it'd be like : xml_dict['title'] which leads has a value of:
- # item.SKU, so in the end, you'd be setting item.SKU to whatever value the Element is:
- #
Advertisement
Add Comment
Please, Sign In to add comment