parse xml

Hidura hidura at gmail.com
Fri Oct 15 15:08:58 EDT 2010


First every element represents a node so you have to use
value=n.childNodes[0].nodeValue with that you'll have the 5000

2010/10/15, kostia <kostya.demchuk at gmail.com>:
> I have xml file:
> <?xml version="1.1" encoding="UTF-8"?>
> <root>
>         <n>50000</n>
> </root>
>
> I want to get the value of n (= 50000) inside my python program, I'm
> doing this:
>
> import xml.dom.minidom
> from xml.dom.minidom import Node
> doc = xml.dom.minidom.parseString("boolean_width.xml")
> n = doc.getElementsByTagName("root")[0].firstChild.nodeValue.strip()
> print n
>
> and it is failed. How to get the value? Please, help.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

-- 
Enviado desde mi dispositivo móvil

Diego I. Hidalgo D.



More information about the Python-list mailing list