﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Honza Mensdorff  / Control chars in XML / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 15:41:26 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]honza.mf (9/4/2011)[/b][hr][quote][b]codebyo (9/3/2011)[/b][hr]Which IE version? One should be very careful to post an answer referring to a specific application without an explicit version. Sorry but not all machines will have the same results in these conditions.Best regards,[/quote]Two or three last versions. Which one have you tried?[/quote]Well, I was using IE 7. An error is shown. The same as of those posts before mine. And I have edited the XML to contain &amp;lt;root&amp;gt;. Not sure what happened then. Maybe it's only me. :-)Best regards,</description><pubDate>Sun, 04 Sep 2011 16:34:11 GMT</pubDate><dc:creator>codebyo</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]codebyo (9/3/2011)[/b][hr]Which IE version? One should be very careful to post an answer referring to a specific application without an explicit version. Sorry but not all machines will have the same results in these conditions.Best regards,[/quote]Two or three last versions. Which one have you tried?</description><pubDate>Sun, 04 Sep 2011 14:40:00 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>Which IE version? One should be very careful to post an answer referring to a specific application without an explicit version. Sorry but not all machines will have the same results in these conditions.Best regards,</description><pubDate>Sat, 03 Sep 2011 15:52:37 GMT</pubDate><dc:creator>codebyo</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>Nice question.  Illustrates how silly some of XML is.</description><pubDate>Sun, 17 Oct 2010 15:37:45 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]honza.mf (5/21/2010)[/b][hr]It can be some error during copy-paste. I had no problem. Where have you copied the XML segment from?Bad thing in these forums is, HTML washes all XML/HTML details away, as you can see in the "source" of your post and the displayed result. And the devil is in details.[/quote]Copied from the output of the SQL.And the XML displayed in my post is exactly the same as what I pasted.</description><pubDate>Fri, 21 May 2010 05:39:31 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Toreador (5/21/2010)[/b][hr]This gives the error:&amp;lt;rows&amp;gt;  &amp;lt;_x0023_t a="&amp;#x0;" /&amp;gt;&amp;lt;/rows&amp;gt;This does not:&amp;lt;rows&amp;gt;  &amp;lt;_x0023_t a="x0;" /&amp;gt;&amp;lt;/rows&amp;gt;[/quote]It can be some error during copy-paste. I had no problem. Where have you copied the XML segment from?Bad thing in these forums is, HTML washes all XML/HTML details away, as you can see in the "source" of your post and the displayed result. And the devil is in details.</description><pubDate>Fri, 21 May 2010 05:35:47 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]honza.mf (5/21/2010)[/b][hr]If you are using Notepad as your text editor, try to use Save As and check file encoding. XMLs work fine with UTF-8. If you have xml declaration, encodings must fit.[/quote]Yes, it's UTF-8.It's definitely related to the invalid characters - if I edit it and remove all the '&amp;#' then it displays fine.This gives the error:&amp;lt;rows&amp;gt;  &amp;lt;_x0023_t a="&amp;#x0;" /&amp;gt;&amp;lt;/rows&amp;gt;This does not:&amp;lt;rows&amp;gt;  &amp;lt;_x0023_t a="x0;" /&amp;gt;&amp;lt;/rows&amp;gt;</description><pubDate>Fri, 21 May 2010 05:22:14 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Toreador (5/21/2010)[/b][hr]Not quite the same, but I've now done exactly the above and get the same error.Note - the error appears in a popup &amp;#119;indow. I've a feeling that depending on your browser settings the error may show as an exclamation mark in the status bar instead, double-clicking shows the error.[/quote]If you are using Notepad as your text editor, try to use Save As and check file encoding. XMLs work fine with UTF-8. If you have xml declaration, encodings must fit.[quote]Just because a browser might display it doesn't mean it's valid!IE can cope with all sorts of invalid HTML as well, making (sometimes correct!) guesses about what is intended, but the HTML is still wrong.[/quote]It's playing with words. XML contains invalid characters. Browsers are allowed to display them.It's in the grey zone; neither valid, nor strictly invalid.You can't compare XML and HTML. XML is very strict, HTML is very relaxed by definition.</description><pubDate>Fri, 21 May 2010 05:17:26 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Toreador (5/21/2010)[/b][hr]Not quite the same, but I've now done exactly the above and get the same error.Note - the error appears in a popup &amp;#119;indow. I've a feeling that depending on your browser settings the error may show as an exclamation mark in the status bar instead, double-clicking shows the error.[/quote]Hmmm, I have no idea than. As indicated previously in this topic, I am far from an IE expert.[quote]Just because a browser might display it doesn't mean it's valid!IE can cope with all sorts of invalid HTML as well, making (sometimes correct!) guesses about what is intended, but the HTML is still wrong.[/quote]Yes, but that is exactly what the correct answer says: the XML contains illegal values, but IE does display them (for me and several others at least).</description><pubDate>Fri, 21 May 2010 04:27:14 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Hugo Kornelis (5/21/2010)[/b][hr]How did you try to open the file? I followed these steps:- Run code with output to text mode- Select output, right-click, Copy- On desktop: right-click, New, Text file- Double-click "new text file.txt"; click edit / paste; save changes and close editor- Right-click "new text file.txt"; click rename; change ".txt" to ".xml"- Double-click "new text file.xml" or right-click, click Open with, Internet Explorer (use Choose program if it's not in the list)[/quote]Not quite the same, but I've now done exactly the above and get the same error.Note - the error appears in a popup &amp;#119;indow. I've a feeling that depending on your browser settings the error may show as an exclamation mark in the status bar instead, double-clicking shows the error.[quote][b]Hugo Kornelis (5/21/2010)[/b][hr]The explanation does not sayy that these characters are invalid in any environment; they are indeed invalid, but browsers may choose to support them anyway. IE does that, Firefox doesn't (I just tested this).[/quote]Just because a browser might display it doesn't mean it's valid!IE can cope with all sorts of invalid HTML as well, making (sometimes correct!) guesses about what is intended, but the HTML is still wrong.</description><pubDate>Fri, 21 May 2010 02:54:45 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Toreador (5/21/2010)[/b][hr][quote][b]Oleg Netchaev (5/20/2010)[/b][hr][code="sql"]select * from #t for xml auto, root('rows');[/code]This will prevent the problems with XML segment problem as the result will include the root element.[/quote]Nope, doesn't work for me, I still get the error "An invalid character was found in text context".Can someone tell me why the answer "XML segment, that is invalid in any environment" is incorrect?Even the explanation seems to say that this is the correct answer'Most of chars used in example are invalid in XML, see http://www.w3.org/TR/REC-xml#charsets.'[/quote]How did you try to open the file? I followed these steps:- Run code with output to text mode- Select output, right-click, Copy- On desktop: right-click, New, Text file- Double-click "new text file.txt"; click edit / paste; save changes and close editor- Right-click "new text file.txt"; click rename; change ".txt" to ".xml"- Double-click "new text file.xml" or right-click, click Open with, Internet Explorer (use Choose program if it's not in the list)The explanation does not sayy that these characters are invalid in any environment; they are indeed invalid, but browsers may choose to support them anyway. IE does that, Firefox doesn't (I just tested this).</description><pubDate>Fri, 21 May 2010 02:29:18 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Oleg Netchaev (5/20/2010)[/b][hr][code="sql"]select * from #t for xml auto, root('rows');[/code]This will prevent the problems with XML segment problem as the result will include the root element.[/quote]Nope, doesn't work for me, I still get the error "An invalid character was found in text context".Can someone tell me why the answer "XML segment, that is invalid in any environment" is incorrect?Even the explanation seems to say that this is the correct answer'Most of chars used in example are invalid in XML, see http://www.w3.org/TR/REC-xml#charsets.'</description><pubDate>Fri, 21 May 2010 02:17:05 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]honza.mf (5/20/2010)[/b][hr][quote][b]malleswarareddy_m (5/20/2010)[/b][hr][quote]Thanks for reply.I know that there are different types out put for xml.Includes For Xml 1)path 2)auto 3)raw 4)explicit.But when i saved this output and opened with IE it shows some error.Even though it will open in ssms.I am using IE which is Old version 6.0.Is this error is due to IE.please explain in brief.[/quote]To open the file in some browser, you have to enclose the generated segment in root element. Some browsers must have XML declaration, some not.Use:[code="xml"]&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&amp;lt;data&amp;gt;Returned segment here&amp;lt;/data&amp;gt;[/code]Be careful with th encoding parameter: it MUST fit the encoding of the file saved.[/quote]That's why i had given the correct query select * from #t for xml AUTO,ROOTyou did not saw my enitre reply.</description><pubDate>Thu, 20 May 2010 23:27:23 GMT</pubDate><dc:creator>malleswarareddy_m</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Oleg Netchaev (5/20/2010)[/b][hr][quote][b]honza.mf (5/20/2010)[/b][hr]Thank you, Hugo, for your help. Lot of people cannot distinguish complete XML file and XML segment.[/quote]Because they cannot, you can ask Steve to edit one of the lines in your question to read[code="sql"]select * from #t for xml auto, root('rows');[/code]This will prevent the problems with XML segment problem as the result will include the root element.Let me say one more time that I really enjoyed the question. Thank you.Oleg[/quote]You are right. It could help. But I don't know, I wanted this question to be more about XML than about SQL. And the fact, query with simple FOR XML AUTO returns XML segment and not complete XML, can be sometimes important.</description><pubDate>Thu, 20 May 2010 22:30:16 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]honza.mf (5/20/2010)[/b][hr]Thank you, Hugo, for your help. Lot of people cannot distinguish complete XML file and XML segment.[/quote]Because they cannot, you can ask Steve to edit one of the lines in your question to read[code="sql"]select * from #t for xml auto, root('rows');[/code]This will prevent the problems with XML segment problem as the result will include the root element.Let me say one more time that I really enjoyed the question. Thank you.Oleg</description><pubDate>Thu, 20 May 2010 15:19:49 GMT</pubDate><dc:creator>Oleg Netchaev</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Hugo Kornelis (5/20/2010)[/b][hr][quote][b]natalie.ignatieva (5/20/2010)[/b][hr]The correct answer is "XML segment, with the integrated parser marking most values illegal, but IE can open this segment surrounded by root element ", but my IE gives me this message:The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. --------------------------------------------------------------------------------Only one top level element is allowed in an XML &amp;#100;ocument. Error processing resource 'file:///C:/Documents and Settings/nign...&amp;lt;_x0023_t a="&amp;#x1;" /&amp;gt;-^[/quote]Did you surround the segment by a root element?[/quote]Thank you, Hugo, for your help. Lot of people cannot distinguish complete XML file and XML segment.</description><pubDate>Thu, 20 May 2010 13:27:44 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]natalie.ignatieva (5/20/2010)[/b][hr]The correct answer is "XML segment, with the integrated parser marking most values illegal, but IE can open this segment surrounded by root element ", but my IE gives me this message:The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. --------------------------------------------------------------------------------Only one top level element is allowed in an XML &amp;#100;ocument. Error processing resource 'file:///C:/Documents and Settings/nign...&amp;lt;_x0023_t a="&amp;#x1;" /&amp;gt;-^[/quote]Did you surround the segment by a root element?</description><pubDate>Thu, 20 May 2010 13:05:21 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>The correct answer is "XML segment, with the integrated parser marking most values illegal, but IE can open this segment surrounded by root element ", but my IE gives me this message:The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. --------------------------------------------------------------------------------Only one top level element is allowed in an XML &amp;#100;ocument. Error processing resource 'file:///C:/Documents and Settings/nign...&amp;lt;_x0023_t a="&amp;#x1;" /&amp;gt;-^</description><pubDate>Thu, 20 May 2010 12:14:13 GMT</pubDate><dc:creator>natalie.ignatieva</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>Damn, should have known. If IE can do something then that makes it valid. Oh, yeah, and should have known that I could add XML code in order for that to happen.</description><pubDate>Thu, 20 May 2010 11:37:50 GMT</pubDate><dc:creator>dunnjoe</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]honza.mf (5/20/2010)[/b][hr][quote][b]malleswarareddy_m (5/20/2010)[/b][hr][quote]To open the file in some browser, you have to enclose the generated segment in root element. Some browsers must have XML declaration, some not.[/code]Hi DrGreat question but you got the answer wrong. There were two answers that were correct, but you are not able to see past your choice. 1. The xml is invalid in all environs. If you leave it as it is and add nothing else that is the truth and a correct answer.2. However, if you are able to add something to the output then the second answer is correct it can work in IE. An example of how you have clouded the logic here is this:Which answer is correct?1. 1 + 1 = 22. 1 + 1 = 3If you said 1 you are wrong. Both 1 and two are correct. You see if you put the output of #2 in IE and enclose the output in this ( answer - 1) both answers will be right. To be valid and logical you need to limit the correct response to the only right response without adding conditions or other items the responder does not know.If you do you it is like playing a card game where you makeup the rules while the game is being played, and the rules can change from hand to hand. That way you are always right and always win, but it is not fair to the other players. </description><pubDate>Thu, 20 May 2010 10:29:16 GMT</pubDate><dc:creator>Miles Neale</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>I got it wrong but I learned a little more about XML, so not entirely a bad thing...</description><pubDate>Thu, 20 May 2010 10:21:19 GMT</pubDate><dc:creator>UMG Developer</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>Nope. You're not alone there. I get errors, too.</description><pubDate>Thu, 20 May 2010 08:18:26 GMT</pubDate><dc:creator>OCTom</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>The point of q QotD is to have some takeaway. I don't see one here. Maybe I'm confused (quite likely), but, the XML comes up with errors and can not be displayed in IE 8 without errors.Not only that, but, who would create code like this anyway with all those errors in XML? I guess I'm just feeling ornery today... sorry. :unsure:</description><pubDate>Thu, 20 May 2010 08:17:44 GMT</pubDate><dc:creator>OCTom</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>like others i found the same error  in set @i += 1 this line of code.after  doing like  this set @i= @i + 1 it will  workand generate xml file with some garbage value .</description><pubDate>Thu, 20 May 2010 07:43:16 GMT</pubDate><dc:creator>amit_adarsh</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>XML is not one of my better skills.  I had to do a bit of research, and some thinking on this one.  Thanks.</description><pubDate>Thu, 20 May 2010 07:03:20 GMT</pubDate><dc:creator>Daniel Bowlin</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>Hi,even me too did same !!!:-):-):-):-):-)</description><pubDate>Thu, 20 May 2010 04:04:02 GMT</pubDate><dc:creator>sharada18</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]malleswarareddy_m (5/20/2010)[/b][hr][quote]Thanks for reply.I know that there are different types out put for xml.Includes For Xml 1)path 2)auto 3)raw 4)explicit.But when i saved this output and opened with IE it shows some error.Even though it will open in ssms.I am using IE which is Old version 6.0.Is this error is due to IE.please explain in brief.[/quote]To open the file in some browser, you have to enclose the generated segment in root element. Some browsers must have XML declaration, some not.Use:[code="xml"]&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&amp;lt;data&amp;gt;Returned segment here&amp;lt;/data&amp;gt;[/code]Be careful with th encoding parameter: it MUST fit the encoding of the file saved.</description><pubDate>Thu, 20 May 2010 03:19:29 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>Am I the only one who gets an error trying to display it in IE? Version 8.0.6001.18702</description><pubDate>Thu, 20 May 2010 03:08:47 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]honza.mf (5/20/2010)[/b][hr][quote][b]malleswarareddy_m (5/20/2010)[/b][hr]Hi,after for xml i executed but it opened on SSMS.But i saved it in the form XML.With IE i am unable to open.With for  xml it shows in different.Please explain in detail abot this characters.but i understand that this char will return the value of the character.suppose char(65) will return A.but and also 32 is space i think.what are the charcters below 32.[/quote]The characters below 32 are control characters. Once upon a time they were used to control devices like terminals or printers. Today only some are used regularly (tab, new line, line feed, esc...), others are used for special purposes.Special position is the very first character char(0): it's typically used as a string terminator in C family languages and many other environments. Always take great care using this special one char.There is at least one other control character: it's backspace (char (127)).WITH XML clause is used to turn standard query output in form of XML. It has several forms - see books online.[/quote]Thanks for reply.I know that there are different types out put for xml.Includes For Xml 1)path 2)auto 3)raw 4)explicit.But when i saved this output and opened with IE it shows some error.Even though it will open in ssms.I am using IE which is Old version 6.0.Is this error is due to IE.please explain in brief.I will open xml without error if we put like thisselect * from #t for xml AUTO,ROOT</description><pubDate>Thu, 20 May 2010 03:08:11 GMT</pubDate><dc:creator>malleswarareddy_m</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Hugo Kornelis (5/20/2010)[/b][hr][quote][b]honza.mf (5/20/2010)[/b][hr][quote][b]Hugo Kornelis (5/20/2010)[/b][hr]@honza.mf: Great question! I never work with XML myself so this was a good learning opportunity.The only thing I like less about the question was that it also required knowledge of IE to assess if the correct options was indeed correct. Had you formulated it as "XML segment, with the integrated parser marking most values illegal, but some browsers may be able to open this segment when surrounded by root element", it would have been completely perfect.[/quote]Nearly same as in previous post to vk-kirov.If I used "some browsers", there could be a lot of posts "I don't care about other browsers, I use MyOwnSuperOne 5.8" ;-)[/quote]Knowledge of the standard is sufficient to answer the question *** I suggested it - as you say in the explanation, "parsers [i]are allowed[/i] to cover other characters". Which ones do and don't use that option is irrelevant, a browser [i]may be able[/i] to open the XML fragment.Your version requires not only knowledge of the w3c standard, but also of the implementation choices IE makes; I am not an IE expert (not even an IE user 99% of the time), so I had no choice but to cheat and test how IE handles these characters in XML.[/quote]You are right. IE is to concrete.</description><pubDate>Thu, 20 May 2010 02:53:09 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]honza.mf (5/20/2010)[/b][hr][quote][b]Hugo Kornelis (5/20/2010)[/b][hr]@honza.mf: Great question! I never work with XML myself so this was a good learning opportunity.The only thing I like less about the question was that it also required knowledge of IE to assess if the correct options was indeed correct. Had you formulated it as "XML segment, with the integrated parser marking most values illegal, but some browsers may be able to open this segment when surrounded by root element", it would have been completely perfect.[/quote]Nearly same as in previous post to vk-kirov.If I used "some browsers", there could be a lot of posts "I don't care about other browsers, I use MyOwnSuperOne 5.8" ;-)[/quote]Knowledge of the standard is sufficient to answer the question *** I suggested it - as you say in the explanation, "parsers [i]are allowed[/i] to cover other characters". Which ones do and don't use that option is irrelevant, a browser [i]may be able[/i] to open the XML fragment.Your version requires not only knowledge of the w3c standard, but also of the implementation choices IE makes; I am not an IE expert (not even an IE user 99% of the time), so I had no choice but to cheat and test how IE handles these characters in XML.</description><pubDate>Thu, 20 May 2010 02:46:23 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]honza.mf (5/20/2010)[/b][hr]I'm using ± standard settings of SSMS and of IE too. I hadn't any error message running the query.You had to have something different.[/quote]Actually on trying it again my memory seems to have edited bits out! I don't get that error immediately, I get it when I view the XML segment and hover over the error highlighting.</description><pubDate>Thu, 20 May 2010 02:43:16 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Toreador (5/20/2010)[/b][hr]I ran the script and got an errorError Character '', hexadecimal value 0x0 is illegal in XML documents.ie the first option, which is not the correct answer.As well as this error, I also got an XML segment, which I surrounded by a root element. Displaying this in IE gives an error'an invalid character was found in text context'.but displays the XML anyway.[/quote]Courious.I'm using ± standard settings of SSMS and of IE too. I hadn't any error message running the query.You had to have something different.</description><pubDate>Thu, 20 May 2010 02:39:34 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]Hugo Kornelis (5/20/2010)[/b][hr]@honza.mf: Great question! I never work with XML myself so this was a good learning opportunity.The only thing I like less about the question was that it also required knowledge of IE to assess if the correct options was indeed correct. Had you formulated it as "XML segment, with the integrated parser marking most values illegal, but some browsers may be able to open this segment when surrounded by root element", it would have been completely perfect.[/quote]Nearly same as in previous post to vk-kirov.If I used "some browsers", there could be a lot of posts "I don't care about other browsers, I use MyOwnSuperOne 5.8" ;-)</description><pubDate>Thu, 20 May 2010 02:35:17 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]vk-kirov (5/20/2010)[/b][hr][quote]Parsers are allowed to cover other characters, that's case of IE and allows this result to be displayed.[/quote]I knew about illegal XML characters, but I felt there was a trick about Internet Explorer, so I cheated :-)Other web browsers (Mozilla Firefox, Opera, and Google Chrome) show an error message about incorrect xml characters when trying to open that XML file. Tricky question about a specific application (IE)...[/quote]Specific application (IE) is so specific I felt free to use it. IE (or it's core) is used so many ways in applications, it's knowledge is fundamental.It's the one browser you find near any SQL Server.I don't use IE if I don't have to.But I use some applications that use it's core.</description><pubDate>Thu, 20 May 2010 02:30:38 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]da-zero (5/20/2010)[/b][hr][quote][b]honza.mf (5/19/2010)[/b][hr][quote][b]Maddy...! (5/19/2010)[/b][hr]hello frnds.... wht ever it may be in order to run completely a block of t-sql code it should be syntax error free i think there is no += operator in database so the code itself is wrong and u cant even think of it running how can you expect us to post answer for it.......[/quote]This code is valid!+= operator is legal in the current version of SQL Server.I expect people to answer questions without running code. I know, I'm old enough to be so naive.[/quote]You should specify which environment is used in the question. As a SQL 2005 user, I saw that there would be an error. You even don't have to run the code to see that.I cannot guess which environment you had in mind.[/quote]SQL Server 2008 has been around long enough that question makers can assume you'd recognise the syntax. If there had been an anwer option that matches what would happen on SQL 2005 ("illegal operator +=" or so), I'd agree with you about the trick question and the need to specify environment. But with the options given, your first impression might have been "syntax error", but then you should have reconsidered after missing that annswer option.As others say, this is just nitpicking; the question was clearly about XML.@honza.mf: Great question! I never work with XML myself so this was a good learning opportunity.The only thing I like less about the question was that it also required knowledge of IE to assess if the correct options was indeed correct. Had you formulated it as "XML segment, with the integrated parser marking most values illegal, but some browsers may be able to open this segment when surrounded by root element", it would have been completely perfect.</description><pubDate>Thu, 20 May 2010 02:29:46 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>I guessed right, but the answer is wrong!I ran the script and got an errorError Character '', hexadecimal value 0x0 is illegal in XML documents.ie the first option, which is not the correct answer.As well as this error, I also got an XML segment, which I surrounded by a root element. Displaying this in IE gives an error'an invalid character was found in text context'.but displays the XML anyway.So the actual answer seems to be a selection of the options.(1) the error is given. Also (3) the XML is invalid in any environment (just because some environment might display it doesn't make it valid). But also (4) IE makes an attempt to display it (though gives an error).</description><pubDate>Thu, 20 May 2010 02:20:16 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote]Parsers are allowed to cover other characters, that's case of IE and allows this result to be displayed.[/quote]I knew about illegal XML characters, but I felt there was a trick about Internet Explorer, so I cheated :-)Other web browsers (Mozilla Firefox, Opera, and Google Chrome) show an error message about incorrect xml characters when trying to open that XML file. Tricky question about a specific application (IE)...</description><pubDate>Thu, 20 May 2010 02:13:42 GMT</pubDate><dc:creator>vk-kirov</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]da-zero (5/20/2010)[/b][hr]Well, it could have been a trick question ;-) :-)[/quote]Yes, it was a trick question :-DNitpickers concentrate on +=, others will find XML category :-P</description><pubDate>Thu, 20 May 2010 01:15:34 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Control chars in XML</title><link>http://www.sqlservercentral.com/Forums/Topic924791-1711-1.aspx</link><description>[quote][b]malleswarareddy_m (5/20/2010)[/b][hr]Hi,after for xml i executed but it opened on SSMS.But i saved it in the form XML.With IE i am unable to open.With for  xml it shows in different.Please explain in detail abot this characters.but i understand that this char will return the value of the character.suppose char(65) will return A.but and also 32 is space i think.what are the charcters below 32.[/quote]The characters below 32 are control characters. Once upon a time they were used to control devices like terminals or printers. Today only some are used regularly (tab, new line, line feed, esc...), others are used for special purposes.Special position is the very first character char(0): it's typically used as a string terminator in C family languages and many other environments. Always take great care using this special one char.There is at least one other control character: it's backspace (char (127)).WITH XML clause is used to turn standard query output in form of XML. It has several forms - see books online.</description><pubDate>Thu, 20 May 2010 01:12:56 GMT</pubDate><dc:creator>honza.mf</dc:creator></item></channel></rss>