XML Export with CDATA or special chars

george175
Member Posts: 26
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
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
0
Answers
-
Hi,
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.0 -
Hi George,
You could use XMLExcape for this:LongTxt := TheXMLDoc.InnerXml; LongTxt := XMLEscaper( LongTxt);
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:LOCAL XMLEscaper(InputTxt : Text) ResultTxt : Text EXIT( Escape.Escape(InputTxt));
Where Escape is a dotnet variable of type: System.Security.SecurityElement.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
0 -
Hi,
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.
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;
george0 -
Remco_Reinking wrote: »Hi George,
You could use XMLExcape for this:LongTxt := TheXMLDoc.InnerXml; LongTxt := XMLEscaper( LongTxt);
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:LOCAL XMLEscaper(InputTxt : Text) ResultTxt : Text EXIT( Escape.Escape(InputTxt));
Where Escape is a dotnet variable of type: System.Security.SecurityElement.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
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 answer0 -
Sample usage:
procedure InsertXMLDocAsElement(TagName : Text;TheXMLDoc : DotNet "System.Xml.XmlDocument") LongTxt := TheXMLDoc.InnerXml; LongTxt := XMLEscaper( LongTxt); IF TagName <> '' THEN Add_Element( TagName, LongTxt,FALSE) ELSE ERROR('Programming error.');
With Add_Element function defined as:procedure Add_Element(ElemTagName : Text;ElemTagValue : Text;OptionalField : Boolean) IF OptionalField AND (ElemTagValue='') THEN EXIT; XMLDOMMgt.AddElementWithPrefix( EnvelopeXmlNode, ElemTagName, ElemTagValue, CurrentPrefix, CurrentNameSpace, CreatedXmlNode);
0 -
Remco_Reinking wrote: »Sample usage:
procedure InsertXMLDocAsElement(TagName : Text;TheXMLDoc : DotNet "System.Xml.XmlDocument") LongTxt := TheXMLDoc.InnerXml; LongTxt := XMLEscaper( LongTxt); IF TagName <> '' THEN Add_Element( TagName, LongTxt,FALSE) ELSE ERROR('Programming error.');
With Add_Element function defined as:procedure Add_Element(ElemTagName : Text;ElemTagValue : Text;OptionalField : Boolean) IF OptionalField AND (ElemTagValue='') THEN EXIT; XMLDOMMgt.AddElementWithPrefix( EnvelopeXmlNode, ElemTagName, ElemTagValue, CurrentPrefix, CurrentNameSpace, CreatedXmlNode);
please and do you know how to change this <?xml version="1.0"> into this:
<?xml version="1.0" encoding="UTF-8"?>0
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