When creating an XDocument I get an XmlException with the following message:
system does not support 'iso-8859-1' encoding line 1, position 31
The first line of the Xml document looks like this:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
Here is the code I use to create the document:
xDoc = XDocument.Load(webResponse.GetResponseStream());
The weird thing is that the exception happens on Chrome and Firefox but not IE8.
Any ideas?
Many browsers do not support this encoding. Basically, you can install a font for whatever language you're trying to display (I'm assuming this is why you're using that encoding). Then, you can embed that font for use on any local machine.
code.google.com/p/chromium/issues/detail?id=31510
bugs.webkit.org/show_bug.cgi?id=22339
I'm seeing similar behavior when downloading an xml doc that is generated by a .NET web service for OData (served locally by IIS 7). It shows up with different content types based on browser. Both the content-type header as well as the first line of the xml file is changing. Putting a breakpoint in and inspecting the "HttpWebResponse" object or using Fiddler shows:
content-type: "application/xml;charset=utf-8" (IE)
content-type: "application/xml;charset=iso-8859-1" (Chrome)
Comparing at first line of the xml
<?xml version="1.0" encoding="utf-8" standalone="yes"?> (IE)
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?> (Chrome)
This is resulting in the default XDocument.Load(webResponse_stream) to fail on Chrome.
Related
My pages are written and declared as XHTML 1.0 Strict. The first lines goes like this:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
Which I belive is correct for a XHTML 1.0 Strict but nevertheless IE11 gives this warning:
HTML1406: Invalid tag start: "<?". Question marks should not start tags. File: default.aspx, Line: 1, Column: 2
Anyone know if this is somthing I should worry about?
The problem is that although you have created a file with an XHTML doctype you have served it using a text/html media type.
So IE11 (and other browsers) treat the file as an HTML file and parse it with their HTML parser. An XML declaration in an HTML file is invalid, and that's what the browser is telling you. If you had served the file with an application/xhtml+xml media type, the browser would have treated the file as XHTML and used its XML parser to parse it. Then the XML declaration would be handled correctly according the XML rules and IE11 would not give you that warning message.
There's no real problem here. The HTML parser will treat the declaration as a bogus comment and just carry on regardless.
For more information you should read Sending XHTML as text/html Considered Harmful and/or HTML 4, HTML 5, XHTML, MIME types - the definitive resource
If you got here because you're working on an old(er) ASP.NET Web Forms app/site... try turning on Compatibility View... that worked for me
I try to see a web page with a xform in xampp-server
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:xf="http://www.w3.org/2002/xhtml">
<head>
There is a model of the form
<xf:model>
<xf:instance>
<person>
<fname />
<lname />
</person>
</xf:instance>
<xf:submission id="form1" method="get" action="submit.asp" />
</xf:model>
and there is the real form
<xf:input ref="fname"><xf:label>First Name</xf:label></xf:input><br />
<xf:input ref="lname"><xf:label>Last Name</xf:label></xf:input><br />
<xf:submit submission="form1"><xf:label>Submit</xf:label></xf:submit>
</body>
</html>
How to see the web page instead of xml-code with error message "This XML file does not appear to have any style information associated with it. The document tree is shown below." in browser? Thank you!
Sadly none of the major browsers support XForms directly. In order to see the XForms running in your browser, you'll need an XForms processor.
In your XAMPP server, the best choice is XSLTForms.
Download it from http://sourceforge.net/projects/xsltforms/ and unpack the files in a folder named xsltforms under the same folder where your page resides.
The next step is to modify your XForms to use the processor. Include the following processing instruction just behind the declaration at the top of the page:
<?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl" ?>
XSLTForms uses an XSL transformation to convert your XForms into an HTML5 form usable by your browser, with a little help of Javascript to handle the XForms behavior.
You can find more information in the XSLTForms website and the wikibook.
I'm trying to get an XSLT stylesheet to output clean(ish) HTML5, which is then being styled with Bootstrap.
To work in IE8 (unfortunately required) it needs a proper
<!DOCTYPE html>
header, which is being rendered via the
<xsl:text disable-output-escaping="yes"><!DOCTYPE html></xml:text>
hack. However, Firefox (22 in case it's relevant) is rendering the DOCTYPE to the user.
Does anyone know a better way to sort this that'll work cross-browser?
There is a "proper" (non-hacky) way of rendering HTML5 with XSLT.
<xsl:output
method="xml"
doctype-system="about:legacy-compat"
encoding="UTF-8"
indent="yes" />
I am writing a simple HTML file. I would like to embed an XML in it. I do this using iFrames. In IE9 the XML is formatted (though it shows activeX warnings). If I run the same code in IE10 I do NOT see the formatting at all. I see only the XML content. However if I open the XML separately I am able to see the formatting.
How do I get the formatting in IE10 inside iframe? Thanks in advance.
Here is my HTML code
<html>
<head>
<title>Test Code</title>
</head>
<body>
<iframe src="sample.xml"></iframe>
</body>
</html>
And my sample.xml is
<?xml version="1.0" encoding="utf-8" ?>
<test>asd</test>
--
Update: Switching the browser to IE8 Standards mode works.
<meta http-equiv="X-UA-Compatible" content="IE=8" />
Is this the only solution or is there an IE10 based better solution for this?
We just had this problem, and found a bunch of questions like this with no answers! Finally we found the answer from Microsoft here: System working as designed :-(
From our friends at Microsoft:
As of IE9, IE has had native support for rendering XML content
including XHTML and SVG. To avoid conflicts with this native support,
the auto-generated tree view for XML was scoped to only apply to
top-level documents. Thus, when XML content is hosted inside an
IFRAME, a tree view will not automatically be generated by default.
However, when the browser is running in Compatibility View, IE tries
to more closely emulate the behavior of previous releases, which is
why the tree view is still displayed under these circumstances.
A php file can read the xml file then compile the xml coloring and output the html code, maybe.
Following site i have build always load in quirks mode which then rise the box model bug for older IE.
site
I have added the document type as xhtml1-strict.dtd and there is no white spaces or BOM characters. When i change the document mode to IE7 or IE8 standers from developer tools it shows the site correctly.
I have try to change the quirks mode loading in many ways but couldnt success. If you guys also dont know how to change to quirks mode loading i would appriciate if any hack to the alligment issue i am getting can be posted.
Thank You.
View source and your first line of code is:
<?xml version="1.0" encoding="UTF-8"?>
You need DOCTYPE to be the very first line.
Edit: You've removed the <?xml...>, but you still have an issue. Line 1 is blank but line 2 contains an invisible character - U+FEFF - the unicode BOM. You'll need to remove that.
Are you using Server-Side Includes or some other server technology that could be joining two files or otherwise adding to the response?
Your page starts exactly like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Lose everything before the DTD (including the blank lines before the xml declaration, which don't show correctly), and it should parse in standards mode.
Another solution is to use the X-UA-Compatible response header, like this:
X-UA-Compatible: IE=8
(or IE=7, or IE=9)
Finally, please do read the MSDN documentation on document compatibility -- it's the definitive resource on the subject.
Update:
Since you are using PHP, and you have a spurious Unicode BOM in your source, it's almost certain that one or more of your PHP source files include a BOM. You need to save them without a BOM and without any other characters before the <?php tag.
To make sure you got them all, write a short program that opens up PHP files and reads the first byte. If it's not '<', then something is probably wrong.
Alternatively, you can use the X-UA-Compatible header as I mention above.
If a doctype that triggers strict mode is preceded by an xml prolog, the page shows in quirks mode.
It looks like the code output does.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
<head>