Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12345»»»

Control chars in XML Expand / Collapse
Author
Message
Posted Thursday, May 20, 2010 2:13 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, May 9, 2014 12:47 AM
Points: 3,448, Visits: 4,407
Parsers are allowed to cover other characters, that's case of IE and allows this result to be displayed.

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)...
Post #924885
Posted Thursday, May 20, 2010 2:20 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 10:26 AM
Points: 1,780, Visits: 6,475
I guessed right, but the answer is wrong!
I ran the script and got an error

Error 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).
Post #924893
Posted Thursday, May 20, 2010 2:29 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:35 PM
Points: 6,043, Visits: 8,324
da-zero (5/20/2010)
honza.mf (5/19/2010)
Maddy...! (5/19/2010)
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.......

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.


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.

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.



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #924897
Posted Thursday, May 20, 2010 2:30 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, September 22, 2014 1:20 AM
Points: 1,387, Visits: 1,315
vk-kirov (5/20/2010)
Parsers are allowed to cover other characters, that's case of IE and allows this result to be displayed.

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)...

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.




See, understand, learn, try, use efficient
© Dr.Plch
Post #924899
Posted Thursday, May 20, 2010 2:35 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, September 22, 2014 1:20 AM
Points: 1,387, Visits: 1,315
Hugo Kornelis (5/20/2010)

@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.

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"




See, understand, learn, try, use efficient
© Dr.Plch
Post #924901
Posted Thursday, May 20, 2010 2:39 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, September 22, 2014 1:20 AM
Points: 1,387, Visits: 1,315
Toreador (5/20/2010)

I ran the script and got an error

Error 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.

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.




See, understand, learn, try, use efficient
© Dr.Plch
Post #924902
Posted Thursday, May 20, 2010 2:43 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 10:26 AM
Points: 1,780, Visits: 6,475
honza.mf (5/20/2010)

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.


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.
Post #924905
Posted Thursday, May 20, 2010 2:46 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:35 PM
Points: 6,043, Visits: 8,324
honza.mf (5/20/2010)
Hugo Kornelis (5/20/2010)

@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.

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"

Knowledge of the standard is sufficient to answer the question *** I suggested it - as you say in the explanation, "parsers are allowed to cover other characters". Which ones do and don't use that option is irrelevant, a browser may be able 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.



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #924908
Posted Thursday, May 20, 2010 2:53 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, September 22, 2014 1:20 AM
Points: 1,387, Visits: 1,315
Hugo Kornelis (5/20/2010)
honza.mf (5/20/2010)
Hugo Kornelis (5/20/2010)

@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.

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"

Knowledge of the standard is sufficient to answer the question *** I suggested it - as you say in the explanation, "parsers are allowed to cover other characters". Which ones do and don't use that option is irrelevant, a browser may be able 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.

You are right. IE is to concrete.




See, understand, learn, try, use efficient
© Dr.Plch
Post #924915
Posted Thursday, May 20, 2010 3:08 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:43 AM
Points: 1,939, Visits: 1,162
honza.mf (5/20/2010)
malleswarareddy_m (5/20/2010)
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.




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.



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 this

select * from #t for xml AUTO,ROOT


Malleswarareddy
I.T.Analyst
MCITP(70-451)
Post #924923
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse