XML nach MySQL

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • XML nach MySQL

    Hallo zusammen,

    stehe vor einem kleinen (für mich jedoch großen) Problem. Habe eine XML-Datei, die quasi eine DB darstellt. Also verschiedene "records". Jeder record hat (meistens) die gleichen Attribute. Jetzt möchte ich ausgewählte Attribute der einzelnen records in eine MySQL-DB laden.

    Meine Idee ist: ich bastele mir eine Art "XML-Parser" (wahrscheinlich viel zu kompliziert), der mein XML-file durchgeht. Und sobald ein bestimmter tag (attribut) gefunden wird, soll
    1. der name des Tags und dann
    2. der inhalt des Tags ausgegeben werden (bzw. in die DB INSERTed werden).

    Ich hoffe ihr versteht, was ich meine. Hier ein Beispiel:

    Code:
    <?xml version="1.0"?>
    <!DOCTYPE PubmedArticleSet PUBLIC "-//NLM//DTD PubMedArticle, 1st January 2007//EN" "http://www.ncbi.nlm.nih.gov/entrez/query/DTD/pubmed_070101.dtd">
    <PubmedArticleSet>
    <PubmedArticle>
        <MedlineCitation Owner="NLM" Status="PubMed-not-MEDLINE">
            <PMID>16993471</PMID>
            <DateCreated>
                <Year>2007</Year>
                <Month>02</Month>
                <Day>05</Day>
            </DateCreated>
            <DateCompleted>
                <Year>2007</Year>
                <Month>02</Month>
                <Day>05</Day>
            </DateCompleted>
            <Article PubModel="Print">
                <Journal>
                    <ISSN IssnType="Print">0022-3751</ISSN>
                    <JournalIssue CitedMedium="Print">
                        <Volume>54</Volume>
                        <Issue>4</Issue>
                        <PubDate>
                            <Year>1920</Year>
                            <Month>Dec</Month>
                            <Day>7</Day>
                        </PubDate>
                    </JournalIssue>
                    <Title>The Journal of physiology</Title>
                    <ISOAbbreviation>J. Physiol. (Lond.)</ISOAbbreviation>
                </Journal>
                <ArticleTitle>Physical exertion, fitness and breathing.</ArticleTitle>
                <Pagination>
                    <MedlinePgn>292-318</MedlinePgn>
                </Pagination>
                <AuthorList CompleteYN="Y">
                    <Author ValidYN="Y">
                        <LastName>Briggs</LastName>
                        <ForeName>H</ForeName>
                        <Initials>H</Initials>
                    </Author>
                </AuthorList>
                <Language>eng</Language>
                <PublicationTypeList>
                    <PublicationType>Journal Article</PublicationType>
                </PublicationTypeList>
            </Article>
            <MedlineJournalInfo>
                <Country>England</Country>
                <MedlineTA>J Physiol</MedlineTA>
                <NlmUniqueID>0266262</NlmUniqueID>
            </MedlineJournalInfo>
        </MedlineCitation>
        <PubmedData>
            <History>
                <PubMedPubDate PubStatus="pubmed">
                    <Year>1920</Year>
                    <Month>12</Month>
                    <Day>7</Day>
                    <Hour>0</Hour>
                    <Minute>0</Minute>
                </PubMedPubDate>
                <PubMedPubDate PubStatus="medline">
                    <Year>1920</Year>
                    <Month>12</Month>
                    <Day>7</Day>
                    <Hour>0</Hour>
                    <Minute>1</Minute>
                </PubMedPubDate>
            </History>
            <PublicationStatus>ppublish</PublicationStatus>
            <ArticleIdList>
                <ArticleId IdType="pubmed">16993471</ArticleId>
            </ArticleIdList>
        </PubmedData>
    </PubmedArticle>
    
    
    <PubmedArticle>
        <MedlineCitation Owner="NLM" Status="PubMed-not-MEDLINE">
            <PMID>16993470</PMID>
            <DateCreated>
                <Year>2007</Year>
                <Month>02</Month>
                <Day>05</Day>
            </DateCreated>
            <DateCompleted>
                <Year>2007</Year>
                <Month>02</Month>
                <Day>05</Day>
            </DateCompleted>
            <Article PubModel="Print">
                <Journal>
                    <ISSN IssnType="Print">0022-3751</ISSN>
                    <JournalIssue CitedMedium="Print">
                        <Volume>54</Volume>
                        <Issue>4</Issue>
                        <PubDate>
                            <Year>1920</Year>
                            <Month>Dec</Month>
                            <Day>7</Day>
                        </PubDate>
                    </JournalIssue>
                    <Title>The Journal of physiology</Title>
                    <ISOAbbreviation>J. Physiol. (Lond.)</ISOAbbreviation>
                </Journal>
                <ArticleTitle>The use of thermionic valves with the string galvanometer.</ArticleTitle>
                <Pagination>
                    <MedlinePgn>287-91</MedlinePgn>
                </Pagination>
                <AuthorList CompleteYN="Y">
                    <Author ValidYN="Y">
                        <LastName>Daly</LastName>
                        <ForeName>I de B</ForeName>
                        <Initials>Ide B</Initials>
                    </Author>
                    <Author ValidYN="Y">
                        <LastName>Shellshear</LastName>
                        <ForeName>K E</ForeName>
                        <Initials>KE</Initials>
                    </Author>
                </AuthorList>
                <Language>eng</Language>
                <PublicationTypeList>
                    <PublicationType>Journal Article</PublicationType>
                </PublicationTypeList>
            </Article>
            <MedlineJournalInfo>
                <Country>England</Country>
                <MedlineTA>J Physiol</MedlineTA>
                <NlmUniqueID>0266262</NlmUniqueID>
            </MedlineJournalInfo>
        </MedlineCitation>
        <PubmedData>
            <History>
                <PubMedPubDate PubStatus="pubmed">
                    <Year>1920</Year>
                    <Month>12</Month>
                    <Day>7</Day>
                    <Hour>0</Hour>
                    <Minute>0</Minute>
                </PubMedPubDate>
                <PubMedPubDate PubStatus="medline">
                    <Year>1920</Year>
                    <Month>12</Month>
                    <Day>7</Day>
                    <Hour>0</Hour>
                    <Minute>1</Minute>
                </PubMedPubDate>
            </History>
            <PublicationStatus>ppublish</PublicationStatus>
            <ArticleIdList>
                <ArticleId IdType="pubmed">16993470</ArticleId>
            </ArticleIdList>
        </PubmedData>
    </PubmedArticle>
    </PubmedArticleSet>
    Das obige Bsp hat also ZWEI records (zwei "PubmedArticles"). Jetzt möchte ich aber NUR z.B. die PMID, Title und die LISTE der Autoren (also dynamisch viele), untergebracht im Tag "AuthorList".

    Wäre super, wenn mir jemand einen guten Tipp geben kann!

    Danke und Grüße,
    winfo

  • #2
    mit sax geht's ganz gut:
    http://de3.php.net/manual/en/ref.xml.php

    Kommentar


    • #3
      penizillin, danke dir für den Tipp. Damit komme ich prima zurecht!

      Gruß,
      squirrel

      Kommentar

      Lädt...
      X