Hi,

I've a xml svg file and I would like to update it with Python.

First, I would like to fetch one dom node with getElementByID. I've one 
issue about this method.

This is my example :

My SVG file :

"""
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg:svg
   xmlns:dc="http://purl.org/dc/elements/1.1/";
   xmlns:cc="http://creativecommons.org/ns#";
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
   xmlns:svg="http://www.w3.org/2000/svg";
   xmlns:xlink="http://www.w3.org/1999/xlink";
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
   width="210mm"
   height="297mm"
   id="svg2383"
   sodipodi:version="0.32"
   inkscape:version="0.46"
   sodipodi:docname="product_page.svg"
   inkscape:output_extension="org.inkscape.output.svg.inkscape">
</svg:svg>
"""

$ ipython

In [1]: from xml.dom import minidom

In [2]: dom1 = minidom.parse("myfile.svg")

In [3]: print(dom1.getElementById(u"svg2383"))
None

In [4]: print(dom1.getElementById("svg2383"))
None

I don't understand why getElementById return always None.

Other example with libxml2dom library :

$ ipython

In [1]: import libxml2dom

In [2]: dom2 = libxml2dom.parseFile("myfile.svg")

In [3]: print(dom2.getElementById(u"svg2383"))
None

In [4]: print(dom2.getElementById("svg2383"))

I don't understand why getElementById return always None.

Well, my final purpose isn't to fetch root dom node but to fetch many 
other sub node.

Thanks for your informations.
Stephane


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to