But I am unable to parse all the nodes of the tree .....especially the
subtree of the main tree
It displays only the sibling not the subtree
Regards
Divya
-----Original Message-----
From: Matthias Berth [mailto:be***@de codon.com]
Sent: Tuesday, December 19, 2006 3:18 PM
To: Divya Prakash
Subject: Re: [Jython-users] ERROR : parsing xml in jython
Hi,
looks like you have to make an InputSource from the file, like so:
from java.io import File, FileReader, StringReader
textReader = FileReader(File (filename))
inputSource = InputSource(tex tReader)
dp.parse(inputS ource)
Hope this helps
Matthias
Divya Prakash schrieb:
Hi All,
I m facing the problem while parsing xml file ..
My code is :-
import sys
from org.apache.xerc es.parsers import DOMParser as dp
import javax.xml.parse rs
infilename = open("mos.xml", "r")
print infilename
def test(infilename ):
"""Parse XML document and show attributes and names.
"""
print infilename
parser = dp()
print parser
gh = parser.parse(in filename)
print gh
doc = parser.getDocum ent()
node = doc.getFirstChi ld()
print "Attributes :"
show_attrs(node )
print "Names:"
show_names(node )