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
Comments
T
I must create that on NAV version 3.7