Skip to content Skip to sidebar Skip to footer

How To Read Cdata From Xml File With Python

I try to parse a large xml file with Python, but when I want to print CDATA information, there are nothing, especially with the 'content' tag for the description My source code loo

Solution 1:

The .characters() function can be called several times, each time with a fragment of the text. You seem to be overwriting self.description with each call.

Try this:

defcharacters(self, content):
    ...
    self.description += content  # Note: '+=', not '='
    ...

and remember to set self.description = "" when you are done with it.

Post a Comment for "How To Read Cdata From Xml File With Python"