Import optional XML fields using SSIS

  • Folks,

    This might be a stupid question, so please pardon my ignorance.

    I have a requirement of importing an XML file to SQL Server db. XML Source is the way to go for. But i have a question, some of the fields in the xml schema have been marked as "min occurs = 0" that means they may or may not occur, now if these certain fields do not appear in the XML file that i am trying to import, will my existing mapping go for a toss?

    It so happened that one of the XML files that i am trying to import did not have one of the fields because of the fact that it was an optional field, as a result i am not seeing this in the node when i click on the Advanced properties.

    How do i let my XML Source know about such fields?

    Thanks in advance.

    Amol

    Amol Naik

  • Your XSD will let the XML Source know that these elements may be there.

    If the elements don't exist in the XML Source, your Data Flow will not blow up because the elements are marked as optional.

  • Thanks Erik. You have been very helpful with my XML questions.

    Yet another question slightly off topic, is there a way to validate XML schema within SSIS ? The requirement is to validate the XML file against the schema and if the validation fails send an email.

    Thanks,

    Amol

    Amol Naik

  • Yes, you can validate the XML. Google ".net validate xml" for examples.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply