From: Keith G Hicks on
Okay, I need to clean up these files. They are coming out of this goofy
system with this header:

<?xml version=?1.0? encoding=?UTF-8??>

The quotes around things are not coming in as quotes. And it's not the
correct encoding anyway. It needs to be this:

<?xml version="1.0" encoding="ISO-8859-1"?>


So I guess I need to change the encoding of each file before I can open it
up as an XML doc and read it there. I have no idea what is the best way to
do this programmatically in vb.net. Do I need to open with StreamWriter or
is there an easier way? I can't find anything out there that explains this
clearly. If I need to do this with streamwriter could someone point me
somewhere that shows how to do this?

Thanks,

Keith


From: Scott M. on

"Keith G Hicks" <krh(a)comcast.net> wrote in message
news:uMeJV7lXKHA.4360(a)TK2MSFTNGP04.phx.gbl...
> Okay, I need to clean up these files. They are coming out of this goofy
> system with this header:
>
> <?xml version=?1.0? encoding=?UTF-8??>
>
> The quotes around things are not coming in as quotes. And it's not the
> correct encoding anyway. It needs to be this:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
>
> So I guess I need to change the encoding of each file before I can open it
> up as an XML doc and read it there. I have no idea what is the best way to
> do this programmatically in vb.net. Do I need to open with StreamWriter or
> is there an easier way? I can't find anything out there that explains this
> clearly. If I need to do this with streamwriter could someone point me
> somewhere that shows how to do this?
>
> Thanks,
>
> Keith

Well, if the XML files were "well-formed", you'd simply load them up into a
W3C compliant XML DOM Document, which Microsoft makes available in the
System.Xml namespace with the XmlDocument class. Now, with LINQ, we also
have the XDocument type, which I believe is much easier to work with and can
be declared with an inference, as in:

Dim someXML = "...xml goes here..."

The problem is that right now, you can't use either of these because your
XML isn't well-formed. Your first goal should be to try to get the XML that
you are initially receiving to be well-formed.

As for the encoding, you can read the original XML into a new XML DOM
Document or XDocument and set the encoding of that new document.

Where are these XML streams coming from in the first place?


From: Keith G Hicks on
Never mind. I figured it out:


Dim TheFileLines As New List(Of String)

TheFileLines.AddRange(System.IO.File.ReadAllLines(xmlFilesLocation & "\" &
sArticleToPost))

TheFileLines.RemoveAt(0)

TheFileLines.Insert(0, "<?xml version=""1.0"" encoding=""ISO-8859-1""?>")

System.IO.File.WriteAllLines(xmlFilesLocation & "\" & sArticleToPost,
TheFileLines.ToArray)





"Keith G Hicks" <krh(a)comcast.net> wrote in message
news:uMeJV7lXKHA.4360(a)TK2MSFTNGP04.phx.gbl...
> Okay, I need to clean up these files. They are coming out of this goofy
> system with this header:
>
> <?xml version=?1.0? encoding=?UTF-8??>
>
> The quotes around things are not coming in as quotes. And it's not the
> correct encoding anyway. It needs to be this:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
>
> So I guess I need to change the encoding of each file before I can open it
> up as an XML doc and read it there. I have no idea what is the best way to
> do this programmatically in vb.net. Do I need to open with StreamWriter or
> is there an easier way? I can't find anything out there that explains this
> clearly. If I need to do this with streamwriter could someone point me
> somewhere that shows how to do this?
>
> Thanks,
>
> Keith
>



From: Scott M. on

"Keith G Hicks" <krh(a)comcast.net> wrote in message
news:%23$$5j2mXKHA.4808(a)TK2MSFTNGP06.phx.gbl...
> Never mind. I figured it out:
>
>
> Dim TheFileLines As New List(Of String)
>
> TheFileLines.AddRange(System.IO.File.ReadAllLines(xmlFilesLocation & "\" &
> sArticleToPost))
>
> TheFileLines.RemoveAt(0)
>
> TheFileLines.Insert(0, "<?xml version=""1.0"" encoding=""ISO-8859-1""?>")
>
> System.IO.File.WriteAllLines(xmlFilesLocation & "\" & sArticleToPost,
> TheFileLines.ToArray)
>
>
>
>
>
> "Keith G Hicks" <krh(a)comcast.net> wrote in message
> news:uMeJV7lXKHA.4360(a)TK2MSFTNGP04.phx.gbl...
>> Okay, I need to clean up these files. They are coming out of this goofy
>> system with this header:
>>
>> <?xml version=?1.0? encoding=?UTF-8??>
>>
>> The quotes around things are not coming in as quotes. And it's not the
>> correct encoding anyway. It needs to be this:
>>
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>
>>
>> So I guess I need to change the encoding of each file before I can open
>> it
>> up as an XML doc and read it there. I have no idea what is the best way
>> to
>> do this programmatically in vb.net. Do I need to open with StreamWriter
>> or
>> is there an easier way? I can't find anything out there that explains
>> this
>> clearly. If I need to do this with streamwriter could someone point me
>> somewhere that shows how to do this?
>>
>> Thanks,
>>
>> Keith

You realize that just because you've said what you want the encoding to be
doesn't mean that the characters are actually encoded that way, right?


From: Keith G Hicks on
They're coming from a crappy Mac system that is very inflexible. They have
almost no control over how these get output. I wish i could get them
well-formed but I'm sort of stuck.


"Scott M." <s-mar(a)nospam.nospam> wrote in message
news:%23ogpCxmXKHA.4788(a)TK2MSFTNGP05.phx.gbl...
>
> "Keith G Hicks" <krh(a)comcast.net> wrote in message
> news:uMeJV7lXKHA.4360(a)TK2MSFTNGP04.phx.gbl...
>> Okay, I need to clean up these files. They are coming out of this goofy
>> system with this header:
>>
>> <?xml version=?1.0? encoding=?UTF-8??>
>>
>> The quotes around things are not coming in as quotes. And it's not the
>> correct encoding anyway. It needs to be this:
>>
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>
>>
>> So I guess I need to change the encoding of each file before I can open
>> it up as an XML doc and read it there. I have no idea what is the best
>> way to do this programmatically in vb.net. Do I need to open with
>> StreamWriter or is there an easier way? I can't find anything out there
>> that explains this clearly. If I need to do this with streamwriter could
>> someone point me somewhere that shows how to do this?
>>
>> Thanks,
>>
>> Keith
>
> Well, if the XML files were "well-formed", you'd simply load them up into
> a W3C compliant XML DOM Document, which Microsoft makes available in the
> System.Xml namespace with the XmlDocument class. Now, with LINQ, we also
> have the XDocument type, which I believe is much easier to work with and
> can be declared with an inference, as in:
>
> Dim someXML = "...xml goes here..."
>
> The problem is that right now, you can't use either of these because your
> XML isn't well-formed. Your first goal should be to try to get the XML
> that you are initially receiving to be well-formed.
>
> As for the encoding, you can read the original XML into a new XML DOM
> Document or XDocument and set the encoding of that new document.
>
> Where are these XML streams coming from in the first place?
>