Problem with import of exported from AX 2012 doc.

Hi everyone.

I have an urgent question.

The version of AX is 2012 R3.

I am exporting XML docs (invoices) to another system. The client requirement is that the encoding of the document is “UTF-8”.

The problem is with the top of the XML document (the XML declaration). The problem is as follows. When I export this document and preview it from Internet Explorer it is ok. The declaration is this " <?xml version="1.0" encoding="UTF-8"?> " , but when I open the document via NetBeans to validate it I see the following " - <?xml version="1.0" encoding="UTF-8" standalone="no"?> ". I see some kind of dash or dot, I am not sure.

Can anyone help me with this problem.

Thanks so much in advance.

Sorry, I don’t understand what’s the problem. Can you elaborate it a little bit?

Yes. Sorry for the small amount of information in the previous post and sorry that I haven’t specify more information about my problem sooner, but I got trouble connecting to Dynamics Users Group these days. The problem is that the client, who needs to import this invoices can’t actually import them. The client get some kind of error, which I don’t know. So… when I export XML document with UTF-8 encoding, and I open this document in NetBeans the document has some symbol in front of the XML declaration like this " - ". It’s some kind of dash, but shorter. Anyway…

My consultant thinks that this can be the problem, because we haven’t been able to import not one invoice. All of the invoices needs to go through manual rework. Basically we do the following - copy this ( <?xml version="1.0" encoding="UTF-8"?> ) and place it on the top of this

( - <?xml version=“1.0” encoding=“UTF-8”? standalone=no> ), but without the brackets of course :slight_smile: . The other option is that the “standalone” somehow makes the troubles. I am not sure. Thanks in advance for your time.

P.S. When I change the encoding to UTF-16, export a document and preview it in NetBeans the small dash " - " is not there. So I think it has something to do with the encoding. The same thing happen when I create XML document through Visual Studio. In UTF-8 it has this small dash, in UTF-16 it doesn’t. Therefore I think that if we finally solve this, and the problem is Encoding it could turn out to be a global problem.

Best regards.

My guess is that your “dash” is actually the Byte Order Mark (BOM). Can you please confirm that you’re talking about BOM?

At the beggining wasn’t sure that this is actually a byte order mark, but now when you asked about it I looked at the file’s Encoding tab when I open it in NotePad++ it is " Encode in UTF-8 " and not " Encode in UTF-8 without BOM". So it might be BOM. But what worries me is the everywhere in the forums people said that the BOM is 3 characters and not 1 like in mine case.

Best regards.

In addition to the post above i think that if I generate the XML document in UTF-8 without BOM, if this “dash” is actually a BOM, this might resolve the problem, but I cant figure out how.

BOM is a sequence of byte, not a character (or characters). What you’ll see depends on which BOM it is and how the application (that you use to open the file) interprets these non-character bytes.

Now when you know it’s BOM, tell us what problem you have with BOM. BOM is a part of XML standard, so there shouldn’t be anything wrong with have it in the file, if the consuming application respects the standard. Nevertheless you can remove it from your file if necessary, because BOM is not required for UTF-8.

Now I can positively say that this is a Byte Order Mark. And now the big question is how can I export the document in UTF-8 Without BOM.

P.S. How can I export XML document without BOM? :slight_smile:

No, the question should be why you need a XML document without BOM. A file with UTF-8 encoding and BOM is still completely valid, so any well-written application should be able to read it correctly.

Even if you decide to remove BOM rather then fixing the consuming application, I can’t tell you how to fix your code unless you tell us how your current code looks like. In some cases, you can’t change the way how the file is generated and you can only change it afterwards.

It does not matter anymore, because I have found my solution in another of your posts (big surprise :slight_smile: ).

This is the link:

I agree with you, that UTF-8 with BOM should be accepted well from the recipient system, but a person cannot argue with his clients and the clients of the clients. I think you will agree with me on that one. :slight_smile:

I decided to export the document without BOM, rather than to change it afterwards.

This is how my solution looked like before the changes:

xmlDoc = XMLDocument::newXML(’<?xml version="1.0" encoding="UTF-8"?>’+rootNode.xml());"%1\%2.xml", ediParameters.EDISaveExportFilePath, invoiceIdForXMLName));

And this is how my solution looked like after the changes:

System.Text.Encoding encoding = new System.Text.UTF8Encoding(false);

xmlDoc = XMLDocument::newXML(’<?xml version="1.0" encoding="UTF-8"?>’+rootNode.xml());

System.IO.File::WriteAllText(fileName, xmlDoc.toString(), encoding);

As it shows in the lines above, I stopped using the save(), and took your advice in the link at the top.

Thanks again for your replies. I don’t know what will do without you.

Have a good evening.