pulldom extracting records from recordset

S.Selvam s.selvamsiva at gmail.com
Fri Aug 7 09:04:01 EDT 2009


On Fri, Aug 7, 2009 at 6:10 PM, S.Selvam <s.selvamsiva at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090807/1161de8a/attachment.html>


More information about the Python-list mailing list