logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ward@hollyyashi.com  
#1 Posted : Thursday, May 27, 2021 3:59:03 AM(UTC)
ward@hollyyashi.com

Rank: Advanced Member

Groups: Registered
Joined: 8/30/2019(UTC)
Posts: 33
United States
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.
tony  
#2 Posted : Thursday, May 27, 2021 5:56:21 PM(UTC)
tony

Rank: Advanced Member

Groups: Registered
Joined: 2/28/2018(UTC)
Posts: 48
United States
Location: Pennsylvani mostly

Was thanked: 7 time(s) in 7 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



ward@hollyyashi.com  
#3 Posted : Thursday, May 27, 2021 11:21:06 PM(UTC)
ward@hollyyashi.com

Rank: Advanced Member

Groups: Registered
Joined: 8/30/2019(UTC)
Posts: 33
United States
Location: Arcata, California

Thanks: 2 times
Worked great. Thanks for your help.
Users browsing this topic
Guest
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.