tags:

views:

31

answers:

1

I'm trying to set an attribute in one of the nodes for my XML as below:

rank = 1
for photo in s:
  image = feed.createElement('Image')
  images.appendChild(image)
  image.setAttribute("rank", rank)
  p = feed.createTextNode(str(main_url+photo.display.url))
  image.appendChild(p)
  rank += 1

This however results in the error: 'int' object has no attribute 'replace' in reference to the line: image.setAttribute("rank", rank) What am I missing?

+1  A: 

The .setAttribute method expects a string, so you will have to convert it:

image.setAttribute("rank", str(rank))
Lukáš Lalinský
Ahhhhh....I've gotta keep remembering these small details...thnx
Stephen