Remove heading on XMLport output?

Alex_Chow
Member Posts: 5,063
Is there a way to remove the heading from the XML export?
For example, how do I remove the
For example, how do I remove the
<?xml version="1.0" encoding="UTF-16" standalone="no" ?>from the 1st line of the XMLport output?
Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
0
Comments
-
what is the reason for removing this?
You need to load the xmlfile after xmlport has been run and remove it through xmldom
Also notice that you are running it in UTF-160 -
This request was made by a vendor of one of our clients. I'm in the process of finding out why as well.
What's wrong with UTF-16?Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
UTF-16 make sometime problems, all depends on how the XML is used...0
-
kine wrote:UTF-16 make sometime problems, all depends on how the XML is used...
What kind of problems can we expect with UTF-16? Is it just general problems in the XML world? Or is it NAV specific?Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
it's nav specific. If you are using message queue if I'm remembering correctly.
As far as request take a look at this thread.
viewtopic.php?f=23&t=31648&hilit=never+forget0 -
The thread was on how to add the XML declaration. I'm trying to remove it.
I don't think XMLport runs any codeunits when writing its output? I also don't find any property settings that removes the declaration line.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
you can't do it with xmlport. you need to do it afterward.
you can pass a blank string to the function processingInstruction. Thus removing it. It doesn't hurt to try it.0 -
Or you can pass the XML into XMLDom and just remove the first node and you are done...0
-
kine wrote:Or you can pass the XML into XMLDom and just remove the first node and you are done...
Whoa... This is getting over complicated to what was suppose to be an hour of work. I think I'll try to work with the vendor to see if they can accept the delcaration. It's suppose to be XML standard anyway.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
I was going to say that it is part of well formed XML and should be accepted by any XML parser. Of course, namespaces are also part of wellformed XML and should also be accepted by XMLPorts, which they aren't...0
-
kine wrote:Or you can pass the XML into XMLDom and just remove the first node and you are done...
We have similar issue, that customers webservice does not accept the first line.
I've port that exports xml file and I'm sending it to the webservice by automation,
You say pass xml into XMLDom, how you remove first node? I'm not sure how to select it,.. this did not work fex:CREATE(XmlDoc); XmlDoc.async := FALSE; XmlDoc.load(Tiedosto); // <-- the xml file // This does not work??? XmlNode := XmlDoc.selectSingleNode('XML'); XmlDoc.removeChild(XmlNode); IF ISCLEAR(XmlHttp) THEN CREATE(XmlHttp); XmlHttp.open('POST', Url, FALSE);
K.S.0 -
lauXmlDom.load(Stream); lauXmlNode := lauXmlDom.firstChild; lauXmlDom.removeChild(lauXmlNode);
0 -
One more thing...
I didn't want to start new topic as this is quite close to the previous one.
As navision leaves empty element tags on the xml file how those elements could be checked and then removed with xmldom?
I'm sure there is a way to check the elements if their values are not set. This would be very usefull with huge invoices, would save alot file size and bandwidth on transfering the file.K.S.0 -
You would have to do it through xmldom. Basically write a generic function that loops through all the children and call it recursively.
You would in the function checked the value of each node and if it's blank, remove the child.0 -
I have a simular problem (trying to delete the <xml>-tag) but I'm not familuar with using the the XML automation objects. Can someone help me where to put the above sollution in my code.
(using NAV 2009 SP1 classic)//XML Export XMLfile.CREATE('F:\Outbound\PO.xml'); XMLfile.CREATEOUTSTREAM(OutStreamObj); XMLPORT.EXPORT(50007,OutStreamObj,gRecPurchaseHeader); XMLfile.CLOSE;
I tried to do the following:
After "XMLfile.CREATEOUTSTREAM(OutStreamObj);" add the code:XMLfile.CREATE('F:\Outbound\PO.xml'); XMLfile.CREATEOUTSTREAM(OutStreamObj); CREATE(lauXmlDom); lauXmlDom.load(OutStreamObj); lauXmlNode := lauXmlDom.firstChild; lauXmlDom.removeChild(lauXmlNode); XMLPORT.EXPORT(50007,OutStreamObj,gRecPurchaseHeader); XMLfile.CLOSE;
What would be the right way to do this?BriteBlue Solutions BV | briteblue.nl0 -
gbierkens wrote:I have a simular problem (trying to delete the <xml>-tag) but I'm not familuar with using the the XML automation objects. Can someone help me where to put the above sollution in my code.
(using NAV 2009 SP1 classic)//XML Export XMLfile.CREATE('F:\Outbound\PO.xml'); XMLfile.CREATEOUTSTREAM(OutStreamObj); XMLPORT.EXPORT(50007,OutStreamObj,gRecPurchaseHeader); XMLfile.CLOSE;
I tried to do the following:
After "XMLfile.CREATEOUTSTREAM(OutStreamObj);" add the code:XMLfile.CREATE('F:\Outbound\PO.xml'); XMLfile.CREATEOUTSTREAM(OutStreamObj); CREATE(lauXmlDom); lauXmlDom.load(OutStreamObj); lauXmlNode := lauXmlDom.firstChild; lauXmlDom.removeChild(lauXmlNode); XMLPORT.EXPORT(50007,OutStreamObj,gRecPurchaseHeader); XMLfile.CLOSE;
What would be the right way to do this?
I'm not 100% sure but the second code seems okay to me or if the remove child does not work then the problem might be in the process queue.
First the load thingy needs the file or stream of string (xml data) where the remove child selects the first element, first child. then remove child nukes the first tag which is probably the <xml> and last the file exports out.
I hope you get it working. It took me a week to get this done first timeK.S.0 -
Something still seems to go wrong. I get the following error:
http://img543.imageshack.us/i/foutmeldingf.png/
Any ideas?BriteBlue Solutions BV | briteblue.nl0 -
I would try it a little differently than what you have...
VAR gRecPurchaseHeader : Record 38 XMLDOMDocument : Automation :'Microsoft XML, v6.0'.DOMDocument; XMLNode : Automation :'Microsoft XML, v6.0'.IXMLDOMNode; TempBlob : Record 99008535; OutStreamObj : OutStream; InStreamObj : InStream; IF ISCLEAR(XMLDOMDocument) THEN BEGIN CREATE(XMLDOMDocument); XMLDOMDocument.async := FALSE; END; TempBlob.Blob.CREATEOUTSTREAM(OutStreamObj); XMLPORT.EXPORT(50007,OutStreamObj,gRecPurchaseHeader); TempBlob.Blob.CREATEINSTREAM(InStreamObj); XMLDOMDocument.load(InStreamObj); XMLNode := XMLDOMDocument.firstChild; XMLDOMDocument.removeChild(XMLNode); XMLDOMDocument.save('F:\Outbound\PO.xml');
This works, I would probably add some more logic in that would give an error/message if there was nothing to do and maybe parameterize the file name for the save though.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