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 12:14 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 11, 2014 4:20 PM
Points: 271, Visits: 389
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="" />
-^
Post #925437
Posted Thursday, May 20, 2010 1:05 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:32 PM
Points: 6,128, Visits: 8,393
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
Post #925460
Posted Thursday, May 20, 2010 1:27 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 27, 2014 5:23 AM
Points: 1,425, Visits: 1,316
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
Post #925474
Posted Thursday, May 20, 2010 3:19 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, November 24, 2014 8:33 AM
Points: 1,676, Visits: 1,760
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
Post #925528
Posted Thursday, May 20, 2010 10:30 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 27, 2014 5:23 AM
Points: 1,425, Visits: 1,316
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
Post #925658
Posted Thursday, May 20, 2010 11:27 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, November 25, 2014 11:09 PM
Points: 1,940, Visits: 1,173
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)
Post #925681
Posted Friday, May 21, 2010 2:17 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 10:22 AM
Points: 1,830, Visits: 6,646
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.'
Post #925743
Posted Friday, May 21, 2010 2:29 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:32 PM
Points: 6,128, Visits: 8,393
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
Post #925748
Posted Friday, May 21, 2010 2:54 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 10:22 AM
Points: 1,830, Visits: 6,646
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.
Post #925760
Posted Friday, May 21, 2010 4:27 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:32 PM
Points: 6,128, Visits: 8,393
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
Post #925807
« Prev Topic | Next Topic »

Add to briefcase «««12345»»

Permissions Expand / Collapse