[solved]XML namespace qualifiers

ta5
Member Posts: 1,164
Hello
I want to create an xml file like this:
So far the following code works, but the element "messageId" is written as "<messageId>, not as "<foo-0001:messageId>"
When I use
Any ideas? Thank you in advance.
Thomas
I want to create an xml file like this:
<?xml version="1.0" encoding="UTF-8" ?> <foo-0001:envelope version="1.0" xmlns:foo-0001="http://www.foo.com/xmlns/foo-0001/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <messageId>1234</messageId> </foo-0001:envelope>
So far the following code works, but the element "messageId" is written as "<messageId>, not as "<foo-0001:messageId>"
CREATE(xmlDoc); xmlMgt.SetNormalCase; xmlProcessingInst:=xmlDoc.createProcessingInstruction('xml','version="1.0" encoding="UTF-8"'); CurrNode := xmlDoc.appendChild(xmlProcessingInst); CurrNode := xmlDoc.createElement('foo-0001:envelope'); CurrNode := xmlDoc.appendChild(CurrNode); xmlMgt.AddAttribute(CurrNode,'version','1.0'); xmlMgt.AddAttribute(CurrNode,'xmlns:foo-0001','http://www.foo.com/xmlns/foo-0001/1'); xmlMgt.AddAttribute(CurrNode,'xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance'); xmlMgt.AddElement(CurrNode,'messageId','1234','',NewChild);
When I use
xmlMgt.AddElement(CurrNode,'foo-0001:messageId','1234','',NewChild);I get the error "Reference to undeclared namespace prefix 'foo-0001'.
Any ideas? Thank you in advance.
Thomas
0
Comments
-
I found the solution \:D/
In cu6224, function AddElement it's better to use "createElement" instead of "createnode".
(Of course I use now a copy of the AddElement-Function.)
Hope this may be helpful for someone else.
Regards
Thomas0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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