xml parsing takes extra spaces.

Posted by SDK on Stack Overflow See other posts from Stack Overflow or by SDK
Published on 2011-02-03T15:31:59Z Indexed on 2011/02/04 7:25 UTC
Read the original article Hit count: 144

Filed under:
|
|

I have been trying to write/parse xml file in python. The tags are very simple

<main>
   <data>
     abcdef
   </data>
</main>

I have written this xml using xml document writer from xml.dom.minidom.

How-ever when i try to parse this and try to fetch data-text value, i get 'abcdef' with spaces/carriage return/newline characters in beg and end. Does parsing does not take of indenting spaces? Following is the parsing snippet (ref from net)

dom = parseString(data)
clipTag = dom.getElementsByTagName('clipdata')[0].toxml()
clipData=clipTag.replace('<clipdata>','').replace('</clipdata>','')

Kindly suggest.

© Stack Overflow or respective owner

Related posts about python

Related posts about Xml