problem with xml file creation
martinspo
Member Posts: 3
Hi,
I write xml file for sending data to web service. I create function that make xml file bu i hawe one problem.
If I add attribute to one node then when i crete next node i get empty attribute. I use functions from "XML DOM Management" codeunit.
Code1 fragment:
CLEARALL;
CREATE(XMLDoc);
XMLDoc.async := FALSE;
XMLMgt.SetNormalCase;
NodeSoapenvEnv := XMLDoc.createNode('1','Envelope','');
XMLDoc.appendChild(NodeSoapenvEnv);
//XMLMgt.AddAttribute(NodeSoapenvEnv, 'xmlns', 'http://schemas.xmlsoap.org/soap/envelope/');
XMLMgt.AddElement(NodeSoapenvEnv,'Body','','',NodeSoapB);
XMLMgt.AddElement(NodeSoapB,'Party','','',NodeParty);
XMLMgt.AddElement(NodeParty,'ChannelId','1','',Node);
XMLMgt.AddElement(NodeParty,'ChannelRef','mref','',Node);
XMLMgt.AddElement(NodeParty,'TransactionId','111','',Node);
Result1:
- <Envelope>
- <Body>
- <Party>
<ChannelId>1</ChannelId>
<ChannelRef>mref</ChannelRef>
<TransactionId>111 </TransactionId>
</Party>
</Body>
</Envelope>
But when I add atribute, then i get empty attribute to next node.
Code 2:
CLEARALL;
CREATE(XMLDoc);
XMLDoc.async := FALSE;
XMLMgt.SetNormalCase;
NodeSoapenvEnv := XMLDoc.createNode('1','Envelope','');
XMLDoc.appendChild(NodeSoapenvEnv);
// add atribute
XMLMgt.AddAttribute(NodeSoapenvEnv, 'xmlns', 'http://schemas.xmlsoap.org/soap/envelope/');
XMLMgt.AddElement(NodeSoapenvEnv,'Body','','',NodeSoapB);
XMLMgt.AddElement(NodeSoapB,'Party','','',NodeParty);
XMLMgt.AddElement(NodeParty,'ChannelId','1','',Node);
XMLMgt.AddElement(NodeParty,'ChannelRef','mref','',Node);
XMLMgt.AddElement(NodeParty,'TransactionId','111','',Node);
Result2:
- <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
- <Body xmlns="">
- <Party>
<ChannelId>1</ChannelId>
<ChannelRef>mref</ChannelRef>
<TransactionId>111</TransactionId>
</Party>
</Body>
</Envelope>
How you can see i get empty atribute xmlns="" on next subnode <Body>, but on next node <Party> is ok without empty atribute!
Maybe someone know aboyt this problem!
Please help me create xml file without emty atribute!
Maybe you know some work around
Thanks,
Martins
I write xml file for sending data to web service. I create function that make xml file bu i hawe one problem.
If I add attribute to one node then when i crete next node i get empty attribute. I use functions from "XML DOM Management" codeunit.
Code1 fragment:
CLEARALL;
CREATE(XMLDoc);
XMLDoc.async := FALSE;
XMLMgt.SetNormalCase;
NodeSoapenvEnv := XMLDoc.createNode('1','Envelope','');
XMLDoc.appendChild(NodeSoapenvEnv);
//XMLMgt.AddAttribute(NodeSoapenvEnv, 'xmlns', 'http://schemas.xmlsoap.org/soap/envelope/');
XMLMgt.AddElement(NodeSoapenvEnv,'Body','','',NodeSoapB);
XMLMgt.AddElement(NodeSoapB,'Party','','',NodeParty);
XMLMgt.AddElement(NodeParty,'ChannelId','1','',Node);
XMLMgt.AddElement(NodeParty,'ChannelRef','mref','',Node);
XMLMgt.AddElement(NodeParty,'TransactionId','111','',Node);
Result1:
- <Envelope>
- <Body>
- <Party>
<ChannelId>1</ChannelId>
<ChannelRef>mref</ChannelRef>
<TransactionId>111 </TransactionId>
</Party>
</Body>
</Envelope>
But when I add atribute, then i get empty attribute to next node.
Code 2:
CLEARALL;
CREATE(XMLDoc);
XMLDoc.async := FALSE;
XMLMgt.SetNormalCase;
NodeSoapenvEnv := XMLDoc.createNode('1','Envelope','');
XMLDoc.appendChild(NodeSoapenvEnv);
// add atribute
XMLMgt.AddAttribute(NodeSoapenvEnv, 'xmlns', 'http://schemas.xmlsoap.org/soap/envelope/');
XMLMgt.AddElement(NodeSoapenvEnv,'Body','','',NodeSoapB);
XMLMgt.AddElement(NodeSoapB,'Party','','',NodeParty);
XMLMgt.AddElement(NodeParty,'ChannelId','1','',Node);
XMLMgt.AddElement(NodeParty,'ChannelRef','mref','',Node);
XMLMgt.AddElement(NodeParty,'TransactionId','111','',Node);
Result2:
- <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
- <Body xmlns="">
- <Party>
<ChannelId>1</ChannelId>
<ChannelRef>mref</ChannelRef>
<TransactionId>111</TransactionId>
</Party>
</Body>
</Envelope>
How you can see i get empty atribute xmlns="" on next subnode <Body>, but on next node <Party> is ok without empty atribute!
Maybe someone know aboyt this problem!
Please help me create xml file without emty atribute!
Maybe you know some work around
Thanks,
Martins
0
Comments
-
Do you have the ability to use XMLPorts?
T0 -
No

I must create that on NAV version 3.70
Categories
- All Categories
- 75 General
- 75 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions