Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Control chars in XML


Control chars in XML

Author
Message
natalie.ignatieva
natalie.ignatieva
SSC Veteran
SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)

Group: General Forum Members
Points: 272 Visits: 438
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 document. Error processing resource 'file:///C:/Documents and Settings/nign...

<_x0023_t a="" />
-^
Hugo Kornelis
Hugo Kornelis
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8317 Visits: 11539
natalie.ignatieva (5/20/2010)
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 document. Error processing resource 'file:///C:/Documents and Settings/nign...

<_x0023_t a="" />
-^

Did you surround the segment by a root element?


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
honza.mf
honza.mf
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1771 Visits: 1323
Hugo Kornelis (5/20/2010)
natalie.ignatieva (5/20/2010)
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 document. Error processing resource 'file:///C:/Documents and Settings/nign...

<_x0023_t a="" />
-^

Did you surround the segment by a root element?


Thank you, Hugo, for your help.
Lot of people cannot distinguish complete XML file and XML segment.



See, understand, learn, try, use efficient
© Dr.Plch
Oleg Netchaev
Oleg Netchaev
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1693 Visits: 1807
honza.mf (5/20/2010)
Thank you, Hugo, for your help.
Lot of people cannot distinguish complete XML file and XML segment.

Because they cannot, you can ask Steve to edit one of the lines in your question to read

select * from #t for xml auto, root('rows');



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
honza.mf
honza.mf
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1771 Visits: 1323
Oleg Netchaev (5/20/2010)
honza.mf (5/20/2010)
Thank you, Hugo, for your help.
Lot of people cannot distinguish complete XML file and XML segment.

Because they cannot, you can ask Steve to edit one of the lines in your question to read

select * from #t for xml auto, root('rows');



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

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.



See, understand, learn, try, use efficient
© Dr.Plch
malleswarareddy_m
malleswarareddy_m
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2009 Visits: 1189
honza.mf (5/20/2010)
malleswarareddy_m (5/20/2010)
[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.


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:
<?xml version="1.0" encoding="utf-8"?>
<data>
Returned segment here
</data>



Be careful with th encoding parameter: it MUST fit the encoding of the file saved.


That's why i had given the correct query

select * from #t for xml AUTO,ROOT

you did not saw my enitre reply.

Malleswarareddy
I.T.Analyst
MCITP(70-451)
Toreador
Toreador
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2410 Visits: 8059
Oleg Netchaev (5/20/2010)

select * from #t for xml auto, root('rows');



This will prevent the problems with XML segment problem as the result will include the root element.


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.'
Hugo Kornelis
Hugo Kornelis
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8317 Visits: 11539
Toreador (5/21/2010)
Oleg Netchaev (5/20/2010)

select * from #t for xml auto, root('rows');



This will prevent the problems with XML segment problem as the result will include the root element.


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

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


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Toreador
Toreador
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2410 Visits: 8059
Hugo Kornelis (5/21/2010)

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)


Not quite the same, but I've now done exactly the above and get the same error.
Note - the error appears in a popup window. 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.

Hugo Kornelis (5/21/2010)
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).


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.
Hugo Kornelis
Hugo Kornelis
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8317 Visits: 11539
Toreador (5/21/2010)
Not quite the same, but I've now done exactly the above and get the same error.
Note - the error appears in a popup window. 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.

Hmmm, I have no idea than. As indicated previously in this topic, I am far from an IE expert.

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.

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


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search