Avatar billede peter_svendsen Nybegynder
16. december 2004 - 11:39 Der er 11 kommentarer og
1 løsning

Access 2003 - Send og modtag XML (VBA?)

(Har haft lidt bøvl ved oprettelsen, så jeg håber ikke det er oprettet to gange)

Jeg har lavet en Access 2003 desktop program(forms & database).

Nedenfor er en beskrivelse af forløbet. Punkt 2 og 4 er programmets XML håndtering og det er her mit problem er.

1. I programmet skal jeg kunne indtaste f.eks. en adresse i et felt, og trykke en søg knap.
2. Dette skal generere en XML fil, som ’sendes’ til en eksisterende web løsning.
Eks.
<Person>
  <adresse>Hovedgaden 12</adresse>
</Person>

3. Web løsningen returnere en eller flere personer der passer på søgekriterierne.
Eks.
<Personer>
  <Person>
      <navn>Ole Hansen</navn>
      <adresse>Hovedgaden 12</adresse>
  </Person>
  <Person>
      <navn>Hanne Hansen</navn>
      <adresse>Hovedgaden 12</adresse>
  </Person>
</Personer>

4. Personerne skal håndteres så jeg kan vise dem på skærmen. Jeg regner med at de kan streames og skrives i en tabel, men har ikke kunnet finde en måde Access 2003/VBA håndtere xml på.


Det er altid muligt at læse/skrive XML som om det bare er tekstfiler, men der må da være noget indbygget VBA der kan bruges...
Avatar billede terry Ekspert
16. december 2004 - 12:57 #1
In Access you can export your data (tables) in XML format.

First design your tables and then make a form using the form wizard.

Now you can enter your data which gets written to your table.
Avatar billede terry Ekspert
16. december 2004 - 14:20 #2
to upload/download your XML files you will need to use FTP there rae NO inbuilt functions for doing this!
Avatar billede terry Ekspert
17. december 2004 - 12:09 #3
do you need help here?
Avatar billede peter_svendsen Nybegynder
18. december 2004 - 12:21 #4
Thanks for answering and sorry for not replying before this.

I have not used enough time looking into your suggestions to see if I can make it work... but I will get back to it.

If I understand you right I need to use forms looking identical with the design of my Import/Export XML files and when sending the xml files back and forth you mention using ftp. I have never played around with ftp in Access but I will look into it.

Thanks once again and sorry for keeping you waiting...
Avatar billede terry Ekspert
18. december 2004 - 14:02 #5
Here is a link on FTP. http://www.mvps.org/access/modules/mdl0015.htm

Make a table for containing your data (navn, adresse ....) then make a form using the form wizard. You use the form fro entering data into your table.

Ince you have some data in the table try exporting the table. You can do this by right clicking on th etable and then choosing Export. Now find XML in the list and folow the guide. You can also work with XML files in code

Here are a few links concerning XML. You can be downloaded an XML parser here.

http://msdn.microsoft.com/XML/XMLDownloads/default.aspx



Some samples.

http://msdn.microsoft.com/XML/XMLCodeSamples/default.aspx



http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconxmldocumentobjectmodeldom.asp



This is an example I used for reading and xml file from Access.
In Access you will need a reference to Microsoft XML (Tools+References menu)

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:\XMLTest.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 

End Function
Avatar billede peter_svendsen Nybegynder
18. december 2004 - 14:10 #6
Thanks a ton. I will test it and get back here afterwards
Avatar billede terry Ekspert
22. december 2004 - 20:22 #7
Hi Peter, hows it going, have you tried it yet?
Avatar billede peter_svendsen Nybegynder
23. december 2004 - 08:06 #8
Hi Terry

I have been sick all week... so I have not been able test your examples...

I have read through your examples but have only read through your examples one time and that is far from enough for me to understand the aproach.

I stumpled upon this link while googling (no idea why I did not find this before I wrote this post)

http://msdn.microsoft.com/office/understanding/access/techarticles/default.aspx?pull=/library/en-us/odc_ac2003_ta/html/odc_accessnewxmlfeatures.asp

Like your links I have not tested these methods, but it seem like importXml and exportXml are meant for solving some of this...

I will return here when I get better (and test the examples)

Sorry for keeping you waiting this long and thanks for checking back =)
Avatar billede terry Ekspert
23. december 2004 - 09:21 #9
Hi Peter, sorry to hear your ill, hopefully your feeling better before Xmas.
The link you gave explains how to import/export an XML file, but still you need to be able to send/receive the file from a web address. Thats if I have understood your question correctly. This is where FTP/HTTP comes in and the link I gave (http://www.mvps.org/access/modules/mdl0015.htm)
show you how to do this from Access.

Anyway, when your feeling better and have studied the examples, get back if you need further help.
Hope your well soon.

mvh og god jul
Terry
Avatar billede peter_svendsen Nybegynder
05. januar 2005 - 14:31 #10
I am finally getting better even though I still have a slamming headache. Well enough about that and back to the problem at hand...

I do not know if it have an impact on the way to handle these things but the XML files have a SOAP tag. I am truly sorry if this change everything.

I have raised the points to 200 because of the long wait and the extra trouble.
Avatar billede peter_svendsen Nybegynder
06. januar 2005 - 16:41 #11
I found out that I needed to use SOAP/Webservice instead of XML/FTP as I thought when I wrote the original question. I have been using lots of time looking through the links and suggestions posted by terry and they answer the question I had to begin with and is therefore accepted.


If someone else need help working with SOAP/Webservice in Access 2003 I can pass on the following link. The link have a good and simple guide on how to work with these things. I had to install the new version of ‘Webservice Toolkit’ as well (there is a link to this on the page).
http://www.microsoft.com/office/previous/xp/webservices/toolkit.asp
Avatar billede terry Ekspert
06. januar 2005 - 19:40 #12
Thanks a lot Peter
I've been trying to reply to your mail all day, I keep getting an error. Hopefully the last on eI sendt from home will get through.
Once again thanks, and for the link too!
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