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 8951535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:41:14+00:00 2026-06-15T13:41:14+00:00

there are many file in a folder named ini an i have to search

  • 0

there are many file in a folder named “ini” an i have to search a file with attribute name
and edit its value, i’ve tried this code:-

import os, glob
from lxml import etree

for filename in glob.glob("./ini/*.xml"):

    xmlData = etree.parse(filename)

    for msg in xmlData.findall("//Value"):
        name = msg.attrib["name"]
        init = msg.attrib["initValue"]
        if name == "attribute name" :
            msg.set("initValue", "0")
            print msg.get('name'), msg.get('initValue')
            print msg.attrib
            print name, init
            print filename

the value is updated only in “msg” not in original file

  • 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-15T13:41:15+00:00Added an answer on June 15, 2026 at 1:41 pm

    So you have reached a point where you have read, parsed and modified the xml file. The last step is missing which is to save the file since the modified version only exists in the memory of your running process.

    with open("outfile.xml", "w") as f:
        f.write(etree.tostring(xmlData))
    

    This will write the modified xml to outfile.xml in a pretty printed (indented) format. You will be able to overwrite the original file by replacing “outfile.xml” with the variable containing your original filename.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many folders have a file.txt. This file.txt have multy line and there
This piece of bash code, shows no folder name while there exists many folders.
I have a sql file generated by mysqldump --all-databases . There are many databases
There are many errors here in SO, but this scenario I think its different.
In my app, I have many constants, so I made a constants file named
I have the following: Folder that contains many files (about 300000), named AllFilesFolder list
I have tried to find a solution to this issue for many hours to
Is there a way of converting special folder paths to a full file name
How many interfaces can a class file implement? Is there a limit on the
i have a json file with many elements like these: { code : hfuiew89,

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.