TankorSmash

for joshy boy

Jul 19th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. xml_dict = {'g:price' : item.Price, #key, 'g:price' is a string, item.Price is a attribute name or whatever
  2.             'title': item.SKU,
  3.             'description' : item.Description} #etc etc
  4.            
  5. xml_dict.keys() #is a list of all the keys in the dict, so 'gprice' and 'title' and 'desc'
  6.  
  7. if reader.Name in xml_dict.keys(): #if the name matches any of the keys  in the dict
  8.     xml_dict[reader.Name] = reader.ReadElemContAsStr() # set the value of the key to the element in the XML
  9.     # line above turns into: item.SKU = reader.ReadElementContentAsString()
  10.    
  11.    
  12.     # example: reader.Name = 'title' so it'd be like : xml_dict['title'] which leads has a value of:
  13.     #   item.SKU, so in the end, you'd be setting item.SKU to whatever value the Element is:
  14.     #
Advertisement
Add Comment
Please, Sign In to add comment