File: ets_gpx.rb

package info (click to toggle)
ruby-libxml 2.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,812 kB
  • sloc: xml: 9,628; ruby: 7,119; ansic: 6,665; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 542 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# encoding: UTF-8

require 'libxml'

100.times do
  doc = XML::Document.new
  doc.encoding = 'UTF-8'

  root = XML::Node.new 'gpx'
  root['version'] = '1.0'
  root['creator'] = 'OpenStreetMap.org'
  root['xmlns'] = "http://www.topografix.com/GPX/1/0/"

  doc.root = root

  track = XML::Node.new 'trk'
  doc.root << track

  trkseg = XML::Node.new 'trkseg'
  track << trkseg

  1.upto(1000) do |n|
    trkpt = XML::Node.new 'trkpt'
    trkpt['lat'] = n.to_s
    trkpt['lon'] = n.to_s
    trkseg << trkpt
  end
end