XML - Parsen in Python

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

Dit artikel is de oplossing voor de problemen die hier geschetst worden: XML importeren (MySQL). De oplossing die hier aangedragen wordt:

  • XML-bestand voorafgaand aan import in MySQL, eerst parsen mbv. Python-script
  • Dit Python-script gebruikt XLST om geneste data als aparte bestanden op te slaan, inclusief sleutels

Waarom deze oplossing?

https://stackoverflow.com/questions/17749406/nested-xml-to-joined-mysql-tables:

For future readers, anytime you nee,d to flatten nested XML files for flatfile import 
such as database tables, consider XSLT, the transformation language used to manipulate 
XML files. Practically all general purpose languages has some library for XSLT 1.0 
processing including Python, PHP, Perl, Java, C#, VB, and others.

Voorbeeld

Zie XSL - Subnodes afsplitsen.

Zie ook