On 10/15/2010 11:19 PM, kostia wrote:
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")
Use parse to parse a file. doc = parse('boolean_width.xml')

n = doc.getElementsByTagName("root")[0].firstChild.nodeValue.strip()
print n

and it is failed. How to get the value? Please, help.

Here's a complete program:

import xml.dom.minidom
from xml.dom.minidom import Node, parse

doc = parse('boolean_width.xml')

my_node_list = doc.getElementsByTagName("n")
my_n_node = my_node_list[0]
my_child = my_n_node.firstChild
my_text = my_child.data



--
With warm regards,
Sudheer. S
Personal home page - http://sudheer.net | Tech Chorus - http://techchorus.net
Web and IT services - http://binaryvibes.co.in
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to