May 20, 2010 at 12:14 pm
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="" />
-^
May 20, 2010 at 1:05 pm
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?
May 20, 2010 at 1:27 pm
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.
May 20, 2010 at 3:19 pm
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
May 20, 2010 at 10:30 pm
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.
May 20, 2010 at 11:27 pm
honza.mf (5/20/2010)
malleswarareddy_m (5/20/2010)
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)
May 21, 2010 at 2:17 am
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.'
May 21, 2010 at 2:29 am
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).
May 21, 2010 at 2:54 am
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.
May 21, 2010 at 4:27 am
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).
May 21, 2010 at 5:17 am
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.
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.
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.
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.
May 21, 2010 at 5:22 am
honza.mf (5/21/2010)
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.
Yes, it's UTF-8.
It's definitely related to the invalid characters - if I edit it and remove all the '&#' then it displays fine.
This gives the error:
<rows>
<_x0023_t a="" />
</rows>
This does not:
<rows>
<_x0023_t a="x0;" />
</rows>
May 21, 2010 at 5:35 am
Toreador (5/21/2010)
This gives the error:<rows>
<_x0023_t a="" />
</rows>
This does not:
<rows>
<_x0023_t a="x0;" />
</rows>
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.
May 21, 2010 at 5:39 am
honza.mf (5/21/2010)
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.
Copied from the output of the SQL.
And the XML displayed in my post is exactly the same as what I pasted.
October 17, 2010 at 3:37 pm
Nice question. Illustrates how silly some of XML is.
Tom
Viewing 15 posts - 31 through 45 (of 47 total)
You must be logged in to reply to this topic. Login to reply