On Fri, Aug 7, 2009 at 6:10 PM, S.Selvam <s.selvams...@gmail.com> wrote:
> Hi all, > > I am using pulldom to handle large xml files.It works fine, but i do not > know how to store a particular set of records(as xml) out of the recordset. > -----------------code--------- > from xml.dom import pulldom > hamlet_file = open("input_xml/inp_test.xml") > events = pulldom.parse(hamlet_file) > for (event, node) in events: > if event == pulldom.START_ELEMENT: > if node.tagName == "Record": > events.expandNode(node) > print node #this does not work as it is a object > ------------------------------ > > Whenever the node name is a Record,i process it. I want to store the all > the nodes meeting my requirement. > For eg,i need output as below, > > <Record> > <a> > <a1>hi</a1> > </a> > <b> > --- > </b> > </Record> > > <Record> > <a> > <a1>hello</a1> > . > . > Where input xml might contain 'n' number of Records. > I have been struggling to figure it out.I would be happy to get a solution > for this. > > -- > Yours, > S.Selvam > Hi all, I just found the solution, *node.toprettyxml()* has done it. -- Yours, S.Selvam
-- http://mail.python.org/mailman/listinfo/python-list