Best way to read/write XML?
#1
What's the best way to read/write XML in an add-on?

For example I attempted to use some of my existing Python code code that uses xml.dom.ext.PrettyPrint, but my add-on reports an error:

from xml.dom.ext import PrettyPrint

fails with "ImportError: No module named ext"

JR
Reply
#2
jhsrennie Wrote:What's the best way to read/write XML in an add-on?

For example I attempted to use some of my existing Python code code that uses xml.dom.ext.PrettyPrint, but my add-on reports an error:

from xml.dom.ext import PrettyPrint

fails with "ImportError: No module named ext"

JR

this is what I did for one of the addons, https://github.com/amet/plugin.audio.sho...lt.py#L178
Reply
#3
You can use also BeautifulSoup, ElementTree, each of them has advantages and disadvantages, the best it to try.
Myself I use beautifulsoup when the content is not well form (BS support tha pretty well), but for performance ElementTree is amazing. DOM I think is not bad either but i didn't play too much with it.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#4
Amet Wrote:this is what I did for one of the addons, https://github.com/amet/plugin.audio.sho...lt.py#L178

Thanks, that did the job :-)

Well, toprettyxml() inserts lots of white space, but toxml() works.

JR
Reply
#5
jhsrennie Wrote:Thanks, that did the job :-)

Well, toprettyxml() inserts lots of white space, but toxml() works.

JR

but its so much prettier Smile
Reply

Logout Mark Read Team Forum Stats Members Help
Best way to read/write XML?0