Comments (4)
Maybe a better solution would be to have an optional param telling the to_xml()
function to pretty-format the xml file.
from gpxpy.
Maybe OR-able flags like
-indent
-separate line per closing tag
-one line per trackpoint (has precedence over line per closing tag)
-CRLF
to_xml ( INDENT | ONELINEPERTRACKPOINT)
from gpxpy.
Well, I agree with you that it would be nice. But on the other side it creates some complexity which I need to take care in the future, and it's not a super-important feature (in 6 years, only you asked for this). Even formatting the XML can easily be done in a script after calling to_xml()
but I think this is something more people will use than having newlines in front of some specific tags.
from gpxpy.
Meanwhile I found a cleaner solution:
def to_xml(tag, attributes=None, content=None, default=None, escape=False):
result = org_to_xml(tag, attributes, content, default, escape)
tag = result.split('>')[0]
if tag[:2] == '\n<' and tag[2:] in ('ele', 'time'):
result = result[1:]
return result
org_to_xml = gpxpy.utils.to_xml
gpxpy.utils.to_xml = to_xml
from gpxpy.
Related Issues (20)
- [newbie] Why is a module imported twice? HOT 1
- Bug in float to string conversion
- Bug: `free variable 'from_start_to_end' referenced before assignment in enclosing scope` HOT 1
- Suggestion: Add project to Code Shelter to get help with project maintenance
- Allow user to enforce Haversine distance
- malformed xml HOT 4
- Proposing a PR to fix a few small typos HOT 2
- Remove waypoint while in loop? HOT 1
- Publish a pure Python wheel to PyPI? HOT 1
- Route issues HOT 7
- Incremental distance / length?
- Cannot parse files where the default namespace is http://www.garmin.com/xmlschemas/TrackPointExtension/v2 HOT 2
- Python GPXPy speed data is missing HOT 3
- coordinate bounding box HOT 2
- metadata error in bounds HOT 1
- Force stdlib etree instead of lxml? HOT 1
- Uphill Downhill are not accurate HOT 2
- GPX parsing not working with extension HOT 2
- NameError: free variable 'from_start_to_end' referenced before assignment in enclosing scope HOT 1
- Setup.py method is being deprecated in python package
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gpxpy.