iso-8859 xml read problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a url which I want to read some xml data from
Changing the encoding is not an option!!!
But i keep getting problems as the xmldocument or xmlreader cant seem to
handle it

Is there any way of reading the data please ?

Tia

Stu
 
Stu said:
Hi,

I have a url which I want to read some xml data from
Changing the encoding is not an option!!!
But i keep getting problems as the xmldocument or xmlreader cant seem to
handle it

Is there any way of reading the data please ?

I've been there. I've hacked around it by skipping over the first line, so
the parser will still think it is UTF-8.

This will give incorrect results if it actually is in iso-8859 format AND it
uses special characters. As Alex implies, some programs producing xml may
not specify the format correctly.

This is a rather crummy solution. But Pocket PC won't read iso-8859 format,
and like you said, changing the format is not an option.

Nathan
 
Hi,

Its not my document it actually data from a site

http://www.bbc.co.uk/travelnews/tpeg/rss.opml
Its acutally rss data using the tpeg xml spec

How do I actually skip the header because
the document.skiptocontent still fails.



Is there any way i can read the data into some sort of stream from a given
url as text
as manually process it.

Some code would be useful please

Tia
 
Hi Nathan,

So please could you share this hack with me
as movetocontent() doesnt seem to work as well

I suppose somehow you could read the data into a text stream
and manually parse it!!
Any code would be appreciated

Tia

Stu
 
Stu said:
Hi Nathan,

So please could you share this hack with me
as movetocontent() doesnt seem to work as well

//open file and read one line
TextReader textreader = new StreamReader(GPXFileName,true);

string line =textreader.ReadLine();

// then create an XML reader

XmlTextReader reader = new XmlTextReader(textreader);


XmlDocument doc = new XmlDocument();

doc.Load(reader);

There may be cases where this can fail.

Nathan
 
thanks Nathan Ill give it ago.
I manged to read the file using a httprequest as a stream
and manually parse and scan it. But obviously its a lot neater if I use xml
dom etc

Stu
 
Hi,

I had the same problem and came up with the following solution:

// Retrieve the XML response document and close the response stream.
// The Server sends the response using iso-8859-1 encoding, which is
// not supported by the .NETCF XML parser. Therefore we start by loading
// the entire response into a String object using the Windows 1252
// encoding, which is almost identical to iso-8859-1 encoding.

string sResp;
Stream aRespStream = aHttpResp.GetResponseStream();
StreamReader aStreamReader = new StreamReader(aRespStream,
Encoding.GetEncoding(1252));

try
{
sResp = aStreamReader.ReadToEnd();
}
finally
{
aStreamReader.Close();
}

// Finally we load the XML from the string into the response DOM. The
// encoding declaration in the string is ignored as the string is always
// Unicode.

xmlResp.LoadXml(sResp);

Cheers,

Andreas Selle
 
Thanks Andreas,

Yeah I had to use the web request bit to
However Im having a problem using it in a timer!!! thats another prob.
Ah ha thanks for the encoding bit.Currently im manually parsing it
with some string instr checks but rather use the standard dom
 
Back
Top