0

I'm writing an xml file from access database to import in some web page, using this:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")

Dim Fileout As Object
Dim myxml As String
Dim rs As DAO.Recordset
Set Fileout = fso.CreateTextFile(strpath, True, True)

myxml = .......

Fileout.Write myxml
Fileout.Close

It writes a an xml file. I use notepad++ to check it and it looks ok, same as the template I've got from the upload site.

I've got this error when I try to validate the file there

The following error occurred: XML-File has invalid syntax. reported error is: javax.xml.bind.UnmarshalException: Content ist nicht zulässig in Prolog. - with >linked exception: [org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: >1; Content ist nicht zulässig in Prolog.]

I then found an xml validator online (https://www.xmlvalidation.com) to look for help and got this:

1   Content is not allowed in prolog.
ÿþ<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

There were no other errors in file.

What are these weird signs at the beginning of my first line and how to prevent this?

I have no experience with xml so far, this is my first attempt, so i'm a bit in the dark here.

bbwolff
  • 99
  • 2
  • 12
  • You're not including the code obtaining your XML, nor the code validating it, nor the XML itself. The code you've included is irrelevant for the question. – Erik A Dec 07 '17 at 09:40
  • it stops at the first line, the code is with the error – bbwolff Dec 07 '17 at 09:44
  • some further comment, looking at suggestions from stackoverflow. I enoded the file to utf-8 no bom in notepad++ and there's no error after that. The question now is, how to do that directly from access – bbwolff Dec 07 '17 at 09:55
  • 1
    https://stackoverflow.com/questions/31435662/vba-save-a-file-with-utf-8-without-bom – Andre Dec 07 '17 at 10:14
  • Thanks, this solved all my issues and I was able to import my data to the website. – bbwolff Dec 07 '17 at 15:20

0 Answers0