[XML-SIG] XML Parsing Newbie

Rbrennan brennan.ron at gmail.com
Tue Nov 25 21:29:39 CET 2008


Hello,

I am a xml parsing newbie and I am having a hard time because I am so new. 
I am trying to parse:

<?xml version="1.0" encoding="UTF-8"?>
<server>
	<config>
		<threads>100</threads>
		<runs>1</runs>
		<duration>200</duration>
		<process>400</process>
		<rampup>500</rampup>
	</config>
</server>

I want to grab the value of threads which is 100, runs which is 1, duration
which is 200, process which is 400, and rampup which is 500.

Here is my febal attempt at getting the values between the tags:

import xml.dom.minidom
import sys

class textHandler:      
    
    def parseFile(self):
      tags =
xml.dom.minidom.parse("/home/grinder/grinder-3.0.1/data/reportsInfo.txt")
      serverelements = tags.getElementsByTagName ( 'server' )
      for server in serverelements:
          print server.childNodes[0].data
          
x = textHandler()
x.parseFile()


Can anyone help?

Thanks,
Ron
-- 
View this message in context: http://www.nabble.com/XML-Parsing-Newbie-tp20689034p20689034.html
Sent from the Python - xml-sig mailing list archive at Nabble.com.



More information about the XML-SIG mailing list