Problem about "addChild" with libxml2 for Python



Hello, everyone

I don't know am i right place here, i found this mailing list at libxml2 website.

Last day, i used libxml2 module for Python too analyze my XML file, but i got a strange result, one other part has been added in the result, like below:


_______________The script:

    spe_nodes = corp.act_type()
    dooooc = libxml2.parseDoc("<acts/>")
    mmerde = dooooc.getRootElement()
    for n in spe_nodes[-1:]: # i tested one node
        print "__________________node context:\n",n
        mmerde.addChild(n)
        print "__________________after addChild:"
        print mmerde
    outfile = open("aaaaact_chat","w")
    dooooc.saveTo(outfile)
    outfile.close()


___________________Result with print:

__________________node context:
<mcesid:act id="Simu-Chat_Test_Room4_S03_00011" tool_ref="Simu-Chat_Test_Room4">
                            <mcesid:author ref="Tc7"/>
                            <mcesid:act_type>
                                <mcesid:chat_act>
                                    <mcesid:c_content>
                                        <mcesid:io select_io="out"/>
                                    </mcesid:c_content>
                                </mcesid:chat_act>
                            </mcesid:act_type>
<mcesid:beginning_date>2001-05-02T18:49:59</mcesid:beginning_date>
                        </mcesid:act>

__________________after addChild:
<acts><mcesid:act id="Simu-Chat_Test_Room4_S03_00011" tool_ref="Simu-Chat_Test_Room4">
                            <mcesid:author ref="Tc7"/>
                            <mcesid:act_type>
                                <mcesid:chat_act>
                                    <mcesid:c_content>
                                        <mcesid:io select_io="out"/>
                                    </mcesid:c_content>
                                </mcesid:chat_act>
                            </mcesid:act_type>
<mcesid:beginning_date>2001-05-02T18:49:59</mcesid:beginning_date>
                        </mcesid:act>

                        <mcesid:act id="Simu_Test_dropbox_E0A2-At-986810686" tool_ref="Simu_Test_dropbox_E0A2">
                            <mcesid:author ref="At"/>
                            <mcesid:act_type>
                                <mcesid:dropbox_act>
                                    <mcesid:file resource_ref="Simu_Test_At_dropbox_E0A2_986810686">
<mcesid:name>bioed.rtf</mcesid:name>
<mcesid:file_type>text/richtext</mcesid:file_type>
<mcesid:description>Texte repr&#xE9;sentant la biographie de
At</mcesid:description>
<mcesid:file_date>2001-04-09T10:04:46</mcesid:file_date>
                                    </mcesid:file>
                                </mcesid:dropbox_act>
                            </mcesid:act_type>
<mcesid:beginning_date>2001-04-09T10:04:46</mcesid:beginning_date>
                        </mcesid:act>

I try to find a solution, but i can't.

Thank you in advance for giving me an idea.

Best Regards.

Kun JIN



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]