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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:44:00+00:00 2026-06-15T07:44:00+00:00

I am getting a path separator error in python 2.6.1. I have not found

  • 0

I am getting a path separator error in python 2.6.1. I have not found this issue with python 2.7.2 version, but unfortunately I need this in 2.6.1 only. Is there any another way to achieve the same? 🙁

my code :-

import xml.etree.ElementTree as ET #version 1.2.6
import sys   

class usersDetail(object): 

    def __init__(self, users=None):
        self.doc = ET.parse("test.xml")
        self.root = self.doc.getroot()

    def final_xml(self,username):
        r = self.root.find("user[@username='user1']") #not working in 2.6.1 :(
        self.root.remove(r)
        print r
        tree = ET.ElementTree(self.root)
        tree.write("msl.xml") 

if __name__ == '__main__':
    parser = usersDetail()
    parser.final_xml("user1") 

test.xml is :-

<?xml version="1.0"?>
<users>
<user afp="yes" cifs="yes"  username="user1" volume="vol" webdev="yes" /></user>
</users>

What this will do is it will remove the xml only if username = username. Thanks in advance for your valuable time.

  • 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-15T07:44:01+00:00Added an answer on June 15, 2026 at 7:44 am

    You are using an XPath expression, that is not supported by the ElementTree version included in Python 2.6. You’ll need to filter for the attribute manually, after a .findall():

    def final_xml(self,username):
        users = self.root.findall("user")
        for user in users:
            if user.attrib.get('username') == 'user1':
                break
        else:
            raise ValueError('No such user')
    
        # `user` is now set to the correct element
        self.root.remove(user)
        print user
        tree = ET.ElementTree(self.root)
        tree.write("msl.xml") 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting an Illegal characters in path error while using XMLTextReader method. Basically, I'm
I've been using this technique for getting the absolute physical path of the running
I am trying to figure why I am getting this error. **Warning: require_once(\C\wamp\www\PHP with
In this header file, I am getting error: unknown type name uint32, uint16. I
I am getting the value for the first three columns, but not the value
Getting this error: Fatal error: require_once() [function.require]: Failed opening required 'db/db.php' (include_path='/home/domain.ru/testerier/sites/application/../library:/home/domain.ru/testerier/sites/library:.:/usr/local/lib/php;/home/domain.ru/testerier/sites/application/models') in /home/domain.ru/testerier/sites/www/index.php
Ooookay. So, I have this annoying issue. I'm calling a css file within an
I'm getting this error when trying to get instanse of class in separated Application
I'm getting this error when trying to do : bundle exec cap deploy RVM
According to rake routes, there's the same path for getting an index of objects

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.