| Author |
ISO-8859-1 encoding question.
|
|
| Jürgen Germonpré 2007-03-07, 6:17 pm |
| Hi,
I'm developing a application that has to communicate with a remote system by
means of XML request/response files.
These files need to be ISO-8859-1 encoded. These files are uploaded to an
FTP and processed by an application that runs on (I presume) an Unix system.
This application is hosted elsewhere and there's almost no support for it.
Strange thing about it, when I FTP my files the system doesn't recognizes
them, so it fails and I often get UTF-8 encode files as response instead of
ISO-8859-1. However, if I email the file as an attachment to the guy that is
supposed to give me the support (but doesn't) and he submits the files
locally, it works....
I'm not a pro in xml, and try to gather information as much as possible. I'm
beginning to thing it has to be encoding-related....
Since my source data is in MSAccess i've programmed it in VBA Access on a
windows xp system. Made a reference to msxml6.dll.
This is some code.
Set objXMLDoc = New DOMDocument
objXMLDoc .createElement("SomeThing")
.....
Set objDocHeader = objXMLDoc .createProcessingInstruction("xml",
"version=""1.0"" encoding=""ISO-8859-1""")
I don't know if this is the right way to set the coding for the file. How
can I be sure that the resulting XML is really ISO-8859-1 encoded and how to
force it in VBA? How can I test it?
The one thing that bothers me is the fact that i can't provide you with any
info about the receiving system. I would me very grateful if I could already
figure out the encoding thing...
Thanks
JG
| |
| Martin Honnen 2007-03-07, 6:17 pm |
| Jürgen Germonpré wrote:
> This is some code.
> Set objXMLDoc = New DOMDocument
> objXMLDoc .createElement("SomeThing")
> ....
>
> Set objDocHeader = objXMLDoc .createProcessingInstruction("xml",
> "version=""1.0"" encoding=""ISO-8859-1""")
>
> I don't know if this is the right way to set the coding for the file. How
> can I be sure that the resulting XML is really ISO-8859-1 encoded and how to
> force it in VBA?
If you create the document in memory with the DOM then make sure you
insert the objDocHeader as the first child in the document e.g.
objXMLDoc.insertBefore objDocHeader, objXMLDoc.firstChild
then once you have created and inserted all nodes simply save the DOM
with the save method e.g.
objXMLDoc.save "file.xml"
That way you should have an ISO-8859-1 encoded XML document.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| |
| Jürgen Germonpré 2007-03-07, 6:17 pm |
| Thank you.
Does it make a difference if you add the header before you add other
elements (like you suggested) or is it ok even if you do it afterwards, but
just before the .save as long as you pass it as .firstchild ?
JG
"Martin Honnen" <mahotrash@yahoo.de> wrote in message
news:usC60EOYHHA.984@TK2MSFTNGP04.phx.gbl...
> Jürgen Germonpré wrote:
>
>
> If you create the document in memory with the DOM then make sure you
> insert the objDocHeader as the first child in the document e.g.
> objXMLDoc.insertBefore objDocHeader, objXMLDoc.firstChild
> then once you have created and inserted all nodes simply save the DOM with
> the save method e.g.
> objXMLDoc.save "file.xml"
> That way you should have an ISO-8859-1 encoded XML document.
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
| |
| Martin Honnen 2007-03-08, 6:16 pm |
| Jürgen Germonpré wrote:
> Does it make a difference if you add the header before you add other
> elements (like you suggested) or is it ok even if you do it afterwards, but
> just before the .save as long as you pass it as .firstchild ?
The XML declaration belongs at the start of the document so you need put
it in before (in the sense of the position) all other nodes. So it is
important where you put the XML declaration, not when you put it in.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| |
| Jürgen Germonpré 2007-03-08, 6:16 pm |
| Okay.
Thanks
"Martin Honnen" <mahotrash@yahoo.de> wrote in message
news:ehll8IYYHHA.1388@TK2MSFTNGP05.phx.gbl...
> Jürgen Germonpré wrote:
>
>
> The XML declaration belongs at the start of the document so you need put
> it in before (in the sense of the position) all other nodes. So it is
> important where you put the XML declaration, not when you put it in.
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |