Checking for RootElement in XML-files
BlackBird
Member Posts: 52
Hi There,
I'm designing an interface between 2 applications based on the exchange of XML-files.
The idea is that the XML-files are saved in a directoryand i have to process the files from this directory. The XML-files can store different data. F.i.: one stores Items and the other stores Customers.
When importing the XML-files i want to check the rootelements in the XMLf-files so that i can trigger the right XML-port.
Example:
XML-file #1 has root element <Items></Items>
XML-file #2 has root element <Customers></Customers>.
I have a codeunit that checks to specified directory for *.xml-files. When i process the directory it has to run XML-port 50.000 when it finds the XML-files with root <Items> and XML-port 50.001 when it finds the XML-file with root <Customer>.
Does anyone have a hint as how to do this?
Thnkx.
Hans
I'm designing an interface between 2 applications based on the exchange of XML-files.
The idea is that the XML-files are saved in a directoryand i have to process the files from this directory. The XML-files can store different data. F.i.: one stores Items and the other stores Customers.
When importing the XML-files i want to check the rootelements in the XMLf-files so that i can trigger the right XML-port.
Example:
XML-file #1 has root element <Items></Items>
XML-file #2 has root element <Customers></Customers>.
I have a codeunit that checks to specified directory for *.xml-files. When i process the directory it has to run XML-port 50.000 when it finds the XML-files with root <Items> and XML-port 50.001 when it finds the XML-file with root <Customer>.
Does anyone have a hint as how to do this?
Thnkx.
Hans
0
Comments
-
Hi BlackBird,
You can use XMLDOM.
xlDoc = Automation 'Microsoft XML, v3.0'.DOMDocument
CASE xmlDoc.documentEmelent.nodeName OF
'Items': bla bla bla.
'Customers': Bla bla bla
END;0 -
Hello Hans,
This worked for me, let me know if this is what you mean..Globals XmlDom Automation 'Microsoft XML, v5.0'.DOMDocument CurrNode Automation 'Microsoft XML, v5.0'.IXMLDOMNode
IF ISCLEAR(tXmlDoc) THEN CREATE(XmlDoc); XmlDoc.load('c:\data.xml'); CurrNode := XmlDoc.selectSingleNode('//item'); IF NOT ISCLEAR(CurrNode) THEN BEGIN << start xmlport item>> END; CurrNode := XmlDoc.selectSingleNode('//customer'); IF NOT ISCLEAR(CurrNode) THEN BEGIN << start xmlport customer>> END;Met vriendelijke groet, best regards,
Rvduuren0 -
Both Rik and Claus,
Tnkx for the reply. Both methods work for me!
Hans0
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
- 333 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 991 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