Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError: [Errno 2] No such file or directory #32

Open
Zijian123123 opened this issue May 1, 2020 · 0 comments
Open

FileNotFoundError: [Errno 2] No such file or directory #32

Zijian123123 opened this issue May 1, 2020 · 0 comments

Comments

@Zijian123123
Copy link

Hi I want to use Python to delete the specific tag in a xml file.
Here is for example what I want to delete: <edge id="-28029380" from="444363583" to="307773297" priority="21" type="railway.highspeed" spreadType="center" shape="30808.38,22280.38 30815.34,22079.71 30818.81,21993.54 30825.20,21825.23 30834.10,21591.29 30834.28,21586.33" bidi="28029380" distance="58689.58"> <lane id="-28029380_0" index="0" allow="rail_fast" speed="55.56" length="691.54" shape="30808.43,22278.88 30815.34,22079.71 30818.81,21993.54 30825.20,21825.23 30834.10,21591.29 30834.23,21587.82"/> </edge>
and here is the python code:
`#!usr/bin/python

-- coding: utf-8 --

import xml.etree.ElementTree as ET
tree = ET.parse(r'C:\Users\zzj\Desktop\test\test.xml')
root = tree.getroot()
animNode = root.find('edge')
if animNode.attrib['type'] == 'railway.highspeed':
root.remove(animNode)
tree.write(r'C:\Users\zzj\Desktop\test\finish.xml')`

then I get the error of FileNotFoundError: [Errno 2] No such file or directory. I tried many time but the path doesn't work, could somebody help?
many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant