Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8628407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:32:07+00:00 2026-06-12T08:32:07+00:00

can anybody tell me how to append xml files using python this is my

  • 0

can anybody tell me how to append xml files using python

this is my file1.xml

<?xml version="1.0"?>
<addressbook>
    <person>
        <name>Eric Idle</name>
        <phone type='fix'>999-999-999</phone>
        <phone type='mobile'>555-555-555</phone>
        <address>
            <street>12, spam road</street>
            <city>London</city>
            <zip>H4B 1X3</zip>
        </address>
    </person>
</addressbook>

and i want to append it to another xml file

<?xml version="1.0"?>

 <note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
 </note>

Is there any module which can do this for me…

and the output i needed is :

<addressbook>
    <person>
        <name>Eric Idle</name>
        <phone type='fix'>999-999-999</phone>
        <phone type='mobile'>555-555-555</phone>
        <address>
            <street>12, spam road</street>
            <city>London</city>
            <zip>H4B 1X3</zip>
        </address>
    </person>
    <note>
        <to>Tove</to>
        <from>Jani</from>
        <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
     </note>
</addressbook>

And for now i need to read xml from files but later i need to get the xml response from server and the convert it into one xml file .So please if any one know that to it will help me alot……

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:32:09+00:00Added an answer on June 12, 2026 at 8:32 am

    EDIT: Removed old answer as the question changed considerably.

    Using lxml:

    addressbook_xml = """<?xml version="1.0"?>
    <addressbook>
        <person>
            <name>Eric Idle</name>
            <phone type='fix'>999-999-999</phone>
            <phone type='mobile'>555-555-555</phone>
            <address>
                <street>12, spam road</street>
                <city>London</city>
                <zip>H4B 1X3</zip>
            </address>
        </person>
    </addressbook>"""
    
    note_xml = """<?xml version="1.0"?>
    
     <note>
        <to>Tove</to>
        <from>Jani</from>
        <heading>Reminder</heading>
        <body>Don't forget me this weekend!</body>
     </note>
    """
    
    from lxml import etree
    
    # XML strings to etree
    addressbook_root = etree.fromstring(addressbook_xml)
    note_root = etree.fromstring(note_xml)
    
    # append the note
    addressbook_root.append(note_root)
    
    # print the new addressbook XML document
    print etree.tostring(addressbook_root)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody tell me why my Async task fails sometimes like this? I tested
Can anybody tell me which View Switcher Control is this in below image.?
can anybody tell me why this works <g:each var=n in=${com.pp.News.list()}> <h2>${n.t}</h2> <p>${n.tx}</p> </g:each> but
can anybody tell how is fragment advantage over using instead of view in android
Can anybody tell me how to make this C code work in C++ please?
Can anybody tell me that what is suitable Xcode version for 10.6.8(snow leopard)?Does Xcode
Can anybody tell me why this doesn't work as expected? <?php $merchant_string = '123-Reg|Woolovers|Roxio|Roxio|BandQ|Roxio|Roxio|Big
Can anybody tell my why this doesn't work in the Android emulator? From the
How to convert Object to List. Can anybody tell me how to fix this
can anybody tell me what is wrong with this code, i am getting the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.