Validating XML before import

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 315hughes
    New Member
    • Nov 2011
    • 44

    Validating XML before import

    Evening all. I am currently importing XML into a Access 2010 table. It works fine just using a basic
    Code:
    Application.ImportXML DataSource:="C:\order.xml", ImportOptions:=acAppendData
    But i am wondering is it possible to have this data validated before it is imported into the tables? Or should this be done be the validation rules when the table designs are created? I have created a XSD file which i understand sets what the XML must look like. I am new to XML so bare with me if it is a simple/daft question.
    Thanks in advance
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32634

    #2
    My usual approach to data validation is to import it into a table with as few restrictions as possible, then check the data before reporting on it, or passing it along to the next stage if all is ok. The next stage is generally a separate table with various restrictions in place. Quite different from the table it's imported into which is as devoid of restrictions as you can get it.

    All that said, I haven't used anything XML specific myself, so there might be something specific to XML which would make the process more straightforward for such work. Let's see what others know.

    Comment

    • Taaner
      New Member
      • Mar 2012
      • 16

      #3
      What do you want to validate?
      - the correct syntax of the xml (have all start tags a closing tag, nested correctly, etc...)
      - validating against a schema
      - the data itself

      For the last one, the solution of NeoPa is common practice. Of course you can also consider to read the xml file as a textfile but then you need to interpret the tags yourself.

      I have no idea if there are functions for xml syntax validation or schema-validation in Access. I guess you can find 3rd party modules on the internet that you can use.
      Another option is to use an external tool that you can call from your application before you do the import.

      Comment

      • 315hughes
        New Member
        • Nov 2011
        • 44

        #4
        Thanks for your reply's. The aim is to ensure that the content(data) in the XML file. Matches what the xsd/schema says it should be. So a integer is an integer and not a string. This possibly may be a task that occurs when the data is extracted from its origin im not sure. Ill have a think about passing the data from table to table to validate it. Thanks for your responses again.

        Comment

        Working...