G
Guest
Consider the following XML document :
<?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>
<title>
</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
</body>
</html>
Let's see the doctype :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
If you use an XmlDocument to handel this xml file :
XmlDocument doc = new XmlDocument();
doc.Load( path ); //using doc.Load( string path )
the XmlDocument will MODIFY the doctype declaration, by appending []
e.g. :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[]>
With that modification, you have a MALFORMED document, wich is NOT VALID !!
---------------------------------------------------------------------------------
Don't wait the next service pack to have a fix.
The easyest way to fix it, is to extends the XmlDocument class
And override the
public XmlDocumentType CreateDocumentType( string name, string publicId,
string systemId, string internalSubset ) method.
public override XmlDocumentType CreateDocumentType( string name,
string publicId, string systemId, string internalSubset )
{
if ( internalSubset != null && internalSubset.Length() == 0 )
return base.CreateDocumentType( name, publicId, systemId,
null );
else
return base.CreateDocumentType( name, publicId, systemId,
internalSubset );
}
Normally, if there are no internalSubset the .NET framework should call
this with null and not with an empty string !! Because it doesn't do it, we
have to do it !!
I hope that microsoft will consider and fix this bug.
I hope that this will help .NET programmers.
Yvesdm
<?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>
<title>
</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
</body>
</html>
Let's see the doctype :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
If you use an XmlDocument to handel this xml file :
XmlDocument doc = new XmlDocument();
doc.Load( path ); //using doc.Load( string path )
the XmlDocument will MODIFY the doctype declaration, by appending []
e.g. :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[]>
With that modification, you have a MALFORMED document, wich is NOT VALID !!
---------------------------------------------------------------------------------
Don't wait the next service pack to have a fix.
The easyest way to fix it, is to extends the XmlDocument class
And override the
public XmlDocumentType CreateDocumentType( string name, string publicId,
string systemId, string internalSubset ) method.
public override XmlDocumentType CreateDocumentType( string name,
string publicId, string systemId, string internalSubset )
{
if ( internalSubset != null && internalSubset.Length() == 0 )
return base.CreateDocumentType( name, publicId, systemId,
null );
else
return base.CreateDocumentType( name, publicId, systemId,
internalSubset );
}
Normally, if there are no internalSubset the .NET framework should call
this with null and not with an empty string !! Because it doesn't do it, we
have to do it !!
I hope that microsoft will consider and fix this bug.
I hope that this will help .NET programmers.
Yvesdm