The way or the best practice of handling XML files which might include unknown elements

pn7pn7 Member Posts: 17
Hi

The situation:
We receive XML data from API which is universal for API-vendors customers.

Our customer only needs certain elements from XML. Some element's may or may not appear in the API response XML.

The problem:
The API vendor might update it's interface which leads to i.e. a new element in response XML.
Which leads to: Our customer's XMLPort can't validate against the changed schema.

The possible solution:
The UseLax property was the best shot to ignore unknown elements, but UseLax needs every element to have property: MinOccurs Once. This causes problem because the current schema has elements which may or may not appear in the API response.

The wanted outcome:
NAV XMLPort to use only elements defined in the XMLPort if they are included in the source data and ignore the rest.

Is this possible with XMLPorts? If not, what is the best practice?


Kind regards,
pn7


Answers

  • vaprogvaprog Member Posts: 1,139
    As far as I know, there is no way to handle this directly with an XMLPort. You have two options:
    1. Use Dotnet to process the file
    2. Use an xml transform to remove unknown elements before you feed it to the XMLPort
Sign In or Register to comment.