Hello to everybody,
Iam trying to export xml from NAV 2015 to another system with WS. Iam using CU XML DOM Management and I need to replace this:
-<Order xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" ControllingInstance="TecCom" Version="4.1" Type="Invoice">
<Document/>
-<OrderHeader OrderType="RequestForOffer">
-<OrderIssueDate>
<Date Format="YYYYMMDD">29.02.16</Date>
</OrderIssueDate>
<CustomerInfo DispatchMode="Normal" Name="KS"/>
-<SellerParty>
<PartyNumber Qualifier="BuyerNumber">BUYERNUMBER</PartyNumber>
</SellerParty>
-<BuyerParty>
<PartyNumber Qualifier="SupplierNumber">SUPPLIERNUBBER</PartyNumber>
</BuyerParty>
<Currency>CZK</Currency>
<OrderProcessing/>
</OrderHeader>
-<OrderItem>
<PositionNumber>1</PositionNumber>
-<RequestedQuantity>
<Quantity>1</Quantity>
</RequestedQuantity>
-<ProductId>
<MakerCode>*</MakerCode>
<ProductNumber>50007543</ProductNumber>
<ProductName>zdvihátko vent.1,5dCi/7,70mm</ProductName>
</ProductId>
<ProductDescription/>
<ItemProcessing/>
</OrderItem>
-<OrderItem>
<PositionNumber>1</PositionNumber>
-<RequestedQuantity>
<Quantity>1</Quantity>
</RequestedQuantity>
-<ProductId>
<MakerCode>*</MakerCode>
<ProductNumber>50007544</ProductNumber>
<ProductName>zdvihátko vent.1,5dCi/7,75mm</ProductName>
</ProductId>
<ProductDescription/>
<ItemProcessing/>
</OrderItem>
</Order>
into this :
<Order xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
;
<Document Type="Invoice" Version="4.1" ControllingInstance="TecCom"/>
<OrderHeader OrderType="RequestForOffer">
<OrderIssueDate>
<Date Format="YYYYMMDD">20160225</Date>
</OrderIssueDate>
<CustomerInfo Name="KS"/>
<SellerParty>
<PartyNumber Qualifier="BuyerNumber">7</PartyNumber>
</SellerParty>
<BuyerParty>
<PartyNumber Qualifier="SupplierNumber">615016</PartyNumber>
</BuyerParty>
<Currency>CZK</Currency>
<OrderProcessing DispatchMode="Normal"/>
</OrderHeader>
<OrderItem>
<PositionNumber>1</PositionNumber>
<RequestedQuantity>
<Quantity>26</Quantity>
</RequestedQuantity>
<ProductId>
<MakerCode>*</MakerCode>
<ProductNumber>50007544</ProductNumber>
</ProductId>
<ProductDescription>
<ProductName>desc</ProductName>
</ProductDescription>
<ItemProcessing/>
</OrderItem>
</Order>
I know , that i have to use cdata or special chars strings, but dont know, how to do it. Is here some possibility to use 'Microsoft XML, v6.0'.IXMLDOMCDATASection or somethig else ???
Thank's to everybody.
George
Answers
I think that you don't need CDATA. < is the same as < and so on. You can create XML by XMLPort directly and you should play with date format, because in the first XML isn't your date formatted accordingly to needed format.
You could use XMLExcape for this:
Where
TheXMLDoc is a dotnet variable of type: System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
and LongTxt is a text variable without length restriction
XMLEscaper is a function:
Where Escape is a dotnet variable of type: System.Security.SecurityElement.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Yes, you are right, but this was just peace of xml. Whole XML is 3 nested xml into one xml:
first one has <element>,
second one - "& l t;ParameterData> & # 1 3 ;"
and last one - "& a m p;lt;/SellerParty&g t;& # 1 3 ;"
-
" - & q u ot;
' - & a p os;
< - & l t;
> - & g t;
& - & a m p;
george
So if i will have LongTxt ='<PartyNumber Qualifier="SupplierNumber">SUPPLIERNUBBER</PartyNumber>'
how can I save it into xml with function addElement in NAV? or which another way i have to use it ?
(NewChildNode := XMLNode.OwnerDocument.CreateNode('element',NodeName,NameSpace);
- XMLNode.AppendChild(NewChildNode))
thx for answer
With Add_Element function defined as:
please and do you know how to change this <?xml version="1.0"> into this:
<?xml version="1.0" encoding="UTF-8"?>