XML File with changing tags

IT-Co+De
IT-Co+De Member Posts: 3
Hi@all,

following problem with xml ports:

A customer is getting different messages via tcp/ip (Socket Bus Adapter-Automation). There is exact one Codeunit to receive the messages, because it is handling the receive-event of the communication component version 2 automation. This codeunit shall decide which xml-port is to be used for processing the incoming data according to the content of the xml-file. Therefore the first 3 tags in each xml-file are defined as "MessageType" "Subtype" and "Sender".
Now i wanted to write a "General Info" XML-Port, which only asks these first 3 tags, compares them with a table (containing these information and an assigned object id) and calls the right xml-port.
Now i have the problem, that there are certainly more than three tags in a file, and as soon as the 4th is reached (which varies from messagetype to messagetype) the xml-port stops with an error (e.g. sales order) "The element <Order> is unexpected".
How do I tell the xml-port to ignore all tags after the <Sender> tag?
Neither CurrXMLPort.SKIP, .QUIT nor .BREAK have worked ...

... confused ...
Dirk

Comments

  • DenSter
    DenSter Member Posts: 8,307
    you'll need to program that with an XMLDOM object. Evaluate the first three tags, and copy the rest into another XMLDOM object, which you then load into an XMLPort. The thing is, an XMLPort looks at the entire document, so if there is an element that is not expected, it will throw an error.
  • IT-Co+De
    IT-Co+De Member Posts: 3
    Hi DenSter,

    Thanx for your Reply. We decided to only use either XML-Port or XMLDOM, because we were afraid that version changes in only one of the different interfaces could lead to problems.
    @all: At least I solved it this way:
    the 3 fields i read in the xml-port were additionally created as globals of a single instance codeunit (with a set-function for each). The xml-import calls the set-functions and fills the globals.
    With "IF <XMLPort>.IMPORT THEN;" I handled the error, so that there is no break.
    ... it works!

    Greetings
    Dirk