XML File with changing tags
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
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
0
Comments
-
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.0
-
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
Dirk0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 327 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
