المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Displaying XHTML elements with namespaces in .NET WebBrowser control



C# Programming
05-11-2012, 09:50 PM
I have an XML document that contains in one element XHTML fragments, specifically one or more p tags, which can contain further XHTML tags such as em, span etc. These are all in an "xhtml" namespace, and the XSD has imported the XHTML strict schema, so all is fine in that regard. My problem is this:

My application needs to display these XHTML paragraphs as a read-only document. My thought was to wrap these in an XHTML document with a namespace specified on the body tag, like this:

</span> </span> Namespaced paragraph from XML A partly italicised paragraph from XML </span>
This way, I wouldn't have to remove all namespaces from the XHTML elements when putting the document together.

When I give this generated document to the System.Windows.Forms.WebBrowser control (.NET 3.0), the two paragraphs flow together and the em is ignored (the same thing occurs in IE8). In other words, the WebBrowser doesn't unserstand the namespace, and treats xhtml:p as an unknown element and ignores it.

In Firefox, however, the two paragraphs FF they are on separate lines with normal paragraph distance, which is what I expected.

I'm curious from a purely academic point of view whether Firefox or IE8 is in the right here, but am more interested in a pragmatic solution to this problem, if one exists.