PC Review


Reply
Thread Tools Rate Thread

Decoding question

 
 
GTi
Guest
Posts: n/a
 
      8th Sep 2006
I have this snippet function:


string buf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rows>\n";
buf += "<row id=\"1\">\n";
buf += "<cell>2</cell>\n";
buf += "<cell>S&P 11</cell>\n";
buf += "</row>\n";

Page.Response.Clear();
Page.Response.ContentType = "text/xml";
Page.Response.Write(buf);
Page.Response.BufferOutput = true;
Page.Response.Expires = 0;
Page.Response.End();

This one gived me a nice error message in the browser:
XML Parsing Error: not well-formed
Location: http://127.0.0.1/xmfile.aspx?DoGenerateXmlFile=1
Line Number 4, Column 10:<cell>S&P 11</cell>

I know this is the most common xml error, but how can I avoid this?
How can I force the output to be UTF-8 encoded ?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2lhcmFuIE8nRG9ubmVsbA==?=
Guest
Posts: n/a
 
      8th Sep 2006
I get the impression the first line with the XML declaration is ignored and
the problem is that you dont close the <rows> element.

HTH

Ciaran O'Donnell

"GTi" wrote:

> I have this snippet function:
>
>
> string buf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rows>\n";
> buf += "<row id=\"1\">\n";
> buf += "<cell>2</cell>\n";
> buf += "<cell>S&P 11</cell>\n";
> buf += "</row>\n";
>
> Page.Response.Clear();
> Page.Response.ContentType = "text/xml";
> Page.Response.Write(buf);
> Page.Response.BufferOutput = true;
> Page.Response.Expires = 0;
> Page.Response.End();
>
> This one gived me a nice error message in the browser:
> XML Parsing Error: not well-formed
> Location: http://127.0.0.1/xmfile.aspx?DoGenerateXmlFile=1
> Line Number 4, Column 10:<cell>S&P 11</cell>
>
> I know this is the most common xml error, but how can I avoid this?
> How can I force the output to be UTF-8 encoded ?
>
>

 
Reply With Quote
 
GTi
Guest
Posts: n/a
 
      8th Sep 2006
Ciaran O'Donnell wrote:
> I get the impression the first line with the XML declaration is ignored and
> the problem is that you dont close the <rows> element.
>
> HTH
>
> Ciaran O'Donnell
>
> "GTi" wrote:
>
> > I have this snippet function:
> >
> >
> > string buf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rows>\n";
> > buf += "<row id=\"1\">\n";
> > buf += "<cell>2</cell>\n";
> > buf += "<cell>S&P 11</cell>\n";
> > buf += "</row>\n";
> >
> > Page.Response.Clear();
> > Page.Response.ContentType = "text/xml";
> > Page.Response.Write(buf);
> > Page.Response.BufferOutput = true;
> > Page.Response.Expires = 0;
> > Page.Response.End();
> >
> > This one gived me a nice error message in the browser:
> > XML Parsing Error: not well-formed
> > Location: http://127.0.0.1/xmfile.aspx?DoGenerateXmlFile=1
> > Line Number 4, Column 10:<cell>S&P 11</cell>
> >
> > I know this is the most common xml error, but how can I avoid this?
> > How can I force the output to be UTF-8 encoded ?
> >
> >


The Rows is closed - just missed that in the snippet - sorry!

 
Reply With Quote
 
S Kachru
Guest
Posts: n/a
 
      8th Sep 2006
Try replacing S&P with S&amp;P



> I have this snippet function:
>
> string buf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rows>\n";
> buf += "<row id=\"1\">\n";
> buf += "<cell>2</cell>\n";
> buf += "<cell>S&P 11</cell>\n";
> buf += "</row>\n";
> Page.Response.Clear();
> Page.Response.ContentType = "text/xml";
> Page.Response.Write(buf);
> Page.Response.BufferOutput = true;
> Page.Response.Expires = 0;
> Page.Response.End();
> This one gived me a nice error message in the browser:
> XML Parsing Error: not well-formed
> Location: http://127.0.0.1/xmfile.aspx?DoGenerateXmlFile=1
> Line Number 4, Column 10:<cell>S&P 11</cell>
> I know this is the most common xml error, but how can I avoid this?
> How can I force the output to be UTF-8 encoded ?
>



 
Reply With Quote
 
Stoitcho Goutsev \(100\)
Guest
Posts: n/a
 
      8th Sep 2006
GTi,

The first error that I get is for using the &. You should use &amp; instead.

The second error is for not closed <rows> tag.

When I fixed bot problems the XML showed up.


--
HTH
Stoitcho Goutsev (100)

"GTi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have this snippet function:
>
>
> string buf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rows>\n";
> buf += "<row id=\"1\">\n";
> buf += "<cell>2</cell>\n";
> buf += "<cell>S&P 11</cell>\n";
> buf += "</row>\n";
>
> Page.Response.Clear();
> Page.Response.ContentType = "text/xml";
> Page.Response.Write(buf);
> Page.Response.BufferOutput = true;
> Page.Response.Expires = 0;
> Page.Response.End();
>
> This one gived me a nice error message in the browser:
> XML Parsing Error: not well-formed
> Location: http://127.0.0.1/xmfile.aspx?DoGenerateXmlFile=1
> Line Number 4, Column 10:<cell>S&P 11</cell>
>
> I know this is the most common xml error, but how can I avoid this?
> How can I force the output to be UTF-8 encoded ?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TNEF question: decoding a date =?Utf-8?B?UGF0YXNuZWxsYQ==?= Microsoft Outlook 3 5th Jul 2007 01:20 PM
encoding/decoding question Bartholomew Simpson Microsoft C# .NET 5 22nd Jun 2007 11:42 AM
Decoding MFM Ed Storage Devices 2 14th Jun 2006 01:14 PM
MPEG-2 decoding chip question George Newton Processors 5 19th Feb 2005 12:22 AM
A question about decoding, substitute or vlookup of character. Alan Pong Microsoft Excel Programming 2 10th Oct 2003 08:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:38 PM.