Avatar billede juks Novice
04. maj 2006 - 13:47 Der er 10 kommentarer og
1 løsning

aflæse xlm domumetn

hej
hvordan får jeg allæst værdier i dette xml doc.
http://www.nationalbanken.dk/dndk/valuta.nsf/valuta.xml

skal kun bruge nogle af kurserne fx USD og EURO
Avatar billede terry Ekspert
04. maj 2006 - 13:49 #1
why dont you import it into Access?
Avatar billede terry Ekspert
04. maj 2006 - 13:49 #2
it is possible to import XML documents into an Access table
Avatar billede juks Novice
04. maj 2006 - 13:53 #3
i need to do it every day ..
isnt it easyer to just read it online ,or ?
if not how do i import it
Avatar billede terry Ekspert
04. maj 2006 - 19:46 #4
you can use FTP/HTTP to download the file http://www.mvps.org/access/modules/mdl0037.htm and then you can Include Microsoft XML in your References so that you can us eit to read the xml file.

This is an example only:

Function ReadXMLDoc()
Dim doc As MSXML2.DOMDocument
Dim nodes As IXMLDOMNodeList
Dim i As Integer

On Error GoTo Proc_ERR

    Set doc = CreateObject("msxml2.DOMDocument")

    doc.async = False
    doc.Load "C:\somefile.xml"

    Set nodes = doc.selectNodes("//invoice")

    Debug.Print nodes.length 'Number of nodes, with base = 0

    For i = 0 To nodes.length - 1

        Debug.Print nodes(i).Attributes.getNamedItem("date").Text

        Debug.Print nodes(i).childNodes(0).Text
        Debug.Print nodes(i).childNodes(1).Text
        Debug.Print nodes(i).childNodes(2).Text
        Debug.Print nodes(i).childNodes(3).Text
        Debug.Print nodes(i).childNodes(4).Text

    Next i

    Exit Function

Proc_ERR:

    MsgBox "Error " & Err.Number & " - " & Err.Description

    Resume Next
End Function
Avatar billede juks Novice
05. maj 2006 - 13:48 #5
hey terry
men jeg forstår ikke kan man ikke aflæse det via nettet uden at skulle hente den ned , hvis man i stedet skriver ..
doc.Load "http://www.nationalbanken.dk/dndk/valuta.nsf/valuta.xml"

det ser ud som om den går på nette og finder den men jeg er ved ikke hvad jeg skrive for at aflæse ...

fx set nodes = ?
Avatar billede terry Ekspert
05. maj 2006 - 14:10 #6
I dont know if its possible to read it directly. If they had a web service which could give you them then you could use this in your Access program.

If I find a solution then I'll get back.
Avatar billede juks Novice
05. maj 2006 - 14:46 #7
but if i download the xml .
what do i have to write in my kode to get the the rates
Avatar billede terry Ekspert
07. maj 2006 - 21:53 #8
if I get time I'lltry and put something together for you
Avatar billede juks Novice
08. maj 2006 - 08:49 #9
thanks
Avatar billede terry Ekspert
08. maj 2006 - 19:46 #10
hi juks
I have now tried reading the XML file but dont seem to be able to. And it isnt possible to import into Access either.
The node names dont seem to be valid because they have spaces in them. So I'm now out of suggestions :o(

I dont know enough about XML to find another way of reading the file.

Sorry
Avatar billede juks Novice
24. maj 2006 - 10:33 #11
I was able to do it here is the solution



Public Sub getXML(sourceFile)
   
    Dim source As MSXML2.DOMDocument
    Dim nodes As IXMLDOMText  'IXLDOMNodeList
   
    Set source = CreateObject("Msxml2.DomDocument")
    source.async = False
    source.setProperty "ServerHTTPRequest", True
    source.load CStr(sourceFile)

    Dim Node, Base, NodeCurrency
    Set Base = source.documentElement.firstChild
    For i = 0 To Base.childNodes.Length - 1
        Code = Base.childNodes.Item(i).getAttribute("code") & ";"
       
        kurs = Base.childNodes.Item(i).getAttribute("rate") & "<br>"
    Next
   
    Set source = Nothing
    Set Base = Nothing
   
End Sub
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester