python - Set auto-incrementing attribute in XML node -
I am trying to set an attribute in one of the nodes below for my XML:
S for images in the rank = 1: 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
The result in this error however: An attribute in the 'int' object 'Replaced'
References to the line: image.setAttribute ("rank", rank)
What do I remember Ha?
A string is expected, so you have to change it:
< Code> image.setAttribute ("rank", str (rank))
Comments
Post a Comment