Ich habe eine XML datei und möchte die Daten daraus importieren und ggf. in eine Datenbank speichern. Mit XML habe ich so gut wie keine Erfahrung daher möchte ich Euch fragen wie ich da am besten vor gehen soll.
Hier mal so eine Datei:
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: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180:
| <?xml version="1.0" encoding="utf-8"?> <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0" creator="Groundspeak, Inc. All Rights Reserved. http://www.groundspeak.com" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak.com/cache/1/0/1 http://www.groundspeak.com/cache/1/0/1/cache.xsd" xmlns="http://www.topografix.com/GPX/1/0"> <name>Cache Listing Generated from Geocaching.com</name> <desc>This is an individual cache generated from Geocaching.com</desc> <author>Account "DjLucky" From Geocaching.com</author> <email>contact@geocaching.com</email> <url>http://www.geocaching.com</url> <urlname>Geocaching - High Tech Treasure Hunting</urlname> <time>2011-05-22T12:33:46.1754834Z</time> <keywords>cache, geocache</keywords> <bounds minlat="49.52415" minlon="8.368283" maxlat="49.527317" maxlon="8.370067" /> <wpt lat="49.527317" lon="8.368767"> <time>2010-12-11T08:00:00Z</time> <name>GC2HCNQ</name> <desc>Kleiner Wald by DjLucky, Multi-cache (2.5/2)</desc> <url>http://www.geocaching.com/seek/cache_details.aspx?guid=a686a64f-6ad4-4dbe-b465-d17ba48326ab</url> <urlname>Kleiner Wald</urlname> <sym>Geocache</sym> <type>Geocache|Multi-cache</type> <groundspeak:cache id="1954575" available="True" archived="False" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1"> <groundspeak:name>Kleiner Wald</groundspeak:name> <groundspeak:placed_by>DjLucky</groundspeak:placed_by> <groundspeak:owner id="3606473">DjLucky</groundspeak:owner> <groundspeak:type>Multi-cache</groundspeak:type> <groundspeak:container>Regular</groundspeak:container> <groundspeak:attributes> <groundspeak:attribute id="32" inc="1">Bicycles</groundspeak:attribute> <groundspeak:attribute id="13" inc="1">Available at all times</groundspeak:attribute> <groundspeak:attribute id="25" inc="1">Parking available</groundspeak:attribute> <groundspeak:attribute id="7" inc="1">Takes less than an hour</groundspeak:attribute> <groundspeak:attribute id="6" inc="1">Recommended for kids</groundspeak:attribute> <groundspeak:attribute id="19" inc="1">Ticks</groundspeak:attribute> </groundspeak:attributes> <groundspeak:difficulty>2.5</groundspeak:difficulty> <groundspeak:terrain>2</groundspeak:terrain> <groundspeak:country>Germany</groundspeak:country> <groundspeak:state>Rheinland-Pfalz</groundspeak:state> <groundspeak:short_description html="True"> </groundspeak:short_description> <groundspeak:long_description html="True"><span id="ctl00_ContentBody_LongDescription3">Dieser Multi führt euch durch ein Landschaftsschutzgebiet und macht sicherlich auch Kindern sehr viel Spaß.</span><br /> </groundspeak:long_description> <groundspeak:encoded_hints>ST 2 --> Aufgabe 2: Mehr als 3 ST 4 --> Baum, abgesägter Ast, ein schmaler Schlitz ST 5 --> Magnetisch Final: Greif ruhig rein!</groundspeak:encoded_hints> <groundspeak:logs> <groundspeak:log id="161782893"> <groundspeak:date>2011-05-20T19:00:00Z</groundspeak:date> <groundspeak:type>Found it</groundspeak:type> <groundspeak:finder id="4394458">jasminsabrina</groundspeak:finder> <groundspeak:text encoded="False">dank warrex und ninawieden unserer schnaggel-AG nach der arbeit gesuch und gefunden zusammen sind wir stark LG jasmin sabrina</groundspeak:text> </groundspeak:log> <groundspeak:log id="161778888"> <groundspeak:date>2011-05-20T19:00:00Z</groundspeak:date> <groundspeak:type>Found it</groundspeak:type> <groundspeak:finder id="4442368">WARrex</groundspeak:finder> <groundspeak:text encoded="False">War schon kurz vorm Verzweifeln aber dann doch mitsamt der gesamten Kraft der Schnaggel AG gefunden :)</groundspeak:text> </groundspeak:log> <groundspeak:log id="151297023"> <groundspeak:date>2011-03-27T19:00:00Z</groundspeak:date> <groundspeak:type>Found it</groundspeak:type> <groundspeak:finder id="1889469">palatinus</groundspeak:finder> <groundspeak:text encoded="False"># 773
Schöne, entspannte Runde durch ein uns bisher nicht bekanntes Gebiet. Bei bestem Frühlingswetter haben wir alle Stationen gut gefunden und alle Aufgaben richtig gelöst. Am Final wurden wir dann vom Owner noch persönlich begrüßt - das nenne ich Service !
Fazit: Klasse Cache mit liebevoll zusammengestellten Stationen, der uns eine Menge Spass gemacht hat.
TFTC !!
In: TB / Out: GC</groundspeak:text> </groundspeak:log> <groundspeak:log id="150825638"> <groundspeak:date>2011-03-25T19:00:00Z</groundspeak:date> <groundspeak:type>Found it</groundspeak:type> <groundspeak:finder id="1464360">RA_</groundspeak:finder> <groundspeak:text encoded="False">Schöne Runde in einem meiner Lieblingswälder. Beim Ziegengehege durfte ich Zeuge einer Zwillingsgeburt werden. Ein fantastisches Erlebnis.</groundspeak:text> </groundspeak:log> <groundspeak:log id="150622399"> <groundspeak:date>2011-03-23T19:00:00Z</groundspeak:date> <groundspeak:type>Found it</groundspeak:type> <groundspeak:finder id="4279629">Herzel84</groundspeak:finder> <groundspeak:text encoded="False">zusammen mit *balu* und Wurtzel gefunden. Super Runde. :-) In: Coin Out: TB</groundspeak:text> </groundspeak:log> <groundspeak:log id="150621734"> <groundspeak:date>2011-03-23T19:00:00Z</groundspeak:date> <groundspeak:type>Found it</groundspeak:type> <groundspeak:finder id="246773">Wurtzel</groundspeak:finder> <groundspeak:text encoded="False">Der zweite. Da wurde echt Herzblut in die Cachebeschreibung rein gesteckt. In: TB</groundspeak:text> </groundspeak:log> <groundspeak:log id="150620690"> <groundspeak:date>2011-03-23T19:00:00Z</groundspeak:date> <groundspeak:type>Found it</groundspeak:type> <groundspeak:finder id="250116">*balu*</groundspeak:finder> <groundspeak:text encoded="False">Gut gefunden zur Feierabend bzw eher Nachtrunde. Haben ein wenig getrödelt und somit war es fast schon dunkel beim Loggen.</groundspeak:text> </groundspeak:log> <groundspeak:log id="138779021"> <groundspeak:date>2010-12-17T20:00:00Z</groundspeak:date> <groundspeak:type>Write note</groundspeak:type> <groundspeak:finder id="3606473">DjLucky</groundspeak:finder> <groundspeak:text encoded="False">Coin abgelegt und Cache kontrolliert. Alles OK!</groundspeak:text> </groundspeak:log> </groundspeak:logs> <groundspeak:travelbugs> <groundspeak:travelbug id="2321386" ref="TB2YPCB"> <groundspeak:name>U.S. Flag Micro Geocoin</groundspeak:name> </groundspeak:travelbug> </groundspeak:travelbugs> </groundspeak:cache> </wpt> <wpt lat="49.52415" lon="8.368583"> <time>2010-11-14T01:10:12.203</time> <name>FN2HCNQ</name> <cmt /> <desc>GC2HCNQ Final</desc> <url>http://www.geocaching.com/seek/wpt.aspx?WID=2a3f5b82-ab38-4228-928f-9f78438be0c5</url> <urlname>GC2HCNQ Final</urlname> <sym>Final Location</sym> <type>Waypoint|Final Location</type> </wpt> <wpt lat="49.527317" lon="8.368767"> <time>2010-11-22T08:26:59.183</time> <name>S12HCNQ</name> <cmt /> <desc>GC2HCNQ Stage 1</desc> <url>http://www.geocaching.com/seek/wpt.aspx?WID=8b17e20b-77df-428a-b994-c206371b4449</url> <urlname>GC2HCNQ Stage 1</urlname> <sym>Question to Answer</sym> <type>Waypoint|Question to Answer</type> </wpt> <wpt lat="49.527217" lon="8.368283"> <time>2010-11-22T08:27:35.403</time> <name>S22HCNQ</name> <cmt /> <desc>GC2HCNQ Stage 2</desc> <url>http://www.geocaching.com/seek/wpt.aspx?WID=f81ba4ed-a609-4748-830b-d559257f64ea</url> <urlname>GC2HCNQ Stage 2</urlname> <sym>Question to Answer</sym> <type>Waypoint|Question to Answer</type> </wpt> <wpt lat="49.526167" lon="8.37"> <time>2010-11-22T08:28:17.56</time> <name>S32HCNQ</name> <cmt /> <desc>GC2HCNQ Stage 3</desc> <url>http://www.geocaching.com/seek/wpt.aspx?WID=8301db8e-4ef0-4e90-bd99-8338687a6d5f</url> <urlname>GC2HCNQ Stage 3</urlname> <sym>Question to Answer</sym> <type>Waypoint|Question to Answer</type> </wpt> <wpt lat="49.5252" lon="8.370067"> <time>2010-11-22T08:29:06.013</time> <name>S42HCNQ</name> <cmt /> <desc>GC2HCNQ Stage 4</desc> <url>http://www.geocaching.com/seek/wpt.aspx?WID=c119efbd-f309-4b9e-ac28-cc4d6d04a5c7</url> <urlname>GC2HCNQ Stage 4</urlname> <sym>Stages of a Multicache</sym> <type>Waypoint|Stages of a Multicache</type> </wpt> <wpt lat="49.524733" lon="8.369167"> <time>2010-11-22T08:29:38.23</time> <name>S52HCNQ</name> <cmt /> <desc>GC2HCNQ Stage 5</desc> <url>http://www.geocaching.com/seek/wpt.aspx?WID=4fd8e338-f4c7-439d-aace-955a0b84647d</url> <urlname>GC2HCNQ Stage 5</urlname> <sym>Stages of a Multicache</sym> <type>Waypoint|Stages of a Multicache</type> </wpt> </gpx> |
Problem ist halt auch das die node "wpt" mehrfach vorkommt.
Nun such ich nach einer Methode diese ganzen Daten so effektiv wie möglich zu importieren und ggf in eine datenbank zu schreiben. Hat jemand eine Idee wie ich für den Import am besten vorgehen kann? Ich nutze NativeXML als parser in D2009.
Danke!