Rank: Advanced Member
Groups: Registered
Joined: 8/30/2019(UTC) Posts: 33 Location: Arcata, California Thanks: 2 times
|
There is a new xs:schema id section that suddenly appeared in the XML output file after the latest update. Unfortunately, this prevents MS Access from importing the file. If I remove the new section from the XML file, the problem goes away. But I can't ask users to edit the exported XML file and I don't really want to write special code to strip out this section. Any better suggestions would be appreciated.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 2/28/2018(UTC) Posts: 65 Location: Pennsylvani mostly Was thanked: 9 time(s) in 9 post(s)
|
Ah, this is on me. I got reacquainted with VBA to see if I could come up with a work-around. The code below takes the full name of the file (including path) that you want to import and copies it to a .1 extension (which I picked arbitrarily - normally, I'd replace ".xml" with ".bak" or something like that. Then it looks at the first four non-blank characters on each line to see if they should be included or discarded. When done, in my tests, the resulted in the original file being importable. I used it like so: RemoveXSD "D:\TestData\TEST.xml" Application.ImportXML DataSource:="D:\TestData\TEST.xml", ImportOptions:=acStructureAndData Are you using the Application.ImportXML method to import or something else? FileCopy should overwrite... I didn't put in any error trapping but I think the only way it could fail is if the target or destination were open (or the destination is read0-only.) I think this will work, I'd Code:
Sub RemoveXSD(filename As String)
Dim testFileName As String
testFileName = filename + ".1"
FileCopy filename, testFileName
Dim s As String ' candidate line
Dim testLine As String
Dim testString As String
Open testFileName For Input As #1
Open filename For Output As #2
Do While Not EOF(1)
Line Input #1, s
testLine = LTrim(s)
testString = Left(testLine, 4)
If testString <> "</xs" And testString <> "<xs:" Then
Print #2, s
End If
Loop
Close #1
Close #2
End Sub
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 8/30/2019(UTC) Posts: 33 Location: Arcata, California Thanks: 2 times
|
Worked great. Thanks for your help.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Red Wing Software Developer Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close