Hi all, I'm currently trying to modify a xhtml document that is being displayed by the new WebBrowser control in .Net 2.0.
Loading the page using the Navigate method works fine, but if I read the document text, modify it inside a XmlDocument and then set the DocumentText from the XmlDocuemt OuterText, it is a roll of the dice as to whether it will be set.
This brings up two issues:
1. The assignment doesn’t seem to stick :-)
2. There is no indication that the assignment has failed.
I can't seem to find an InvalidHtml event, and no exception is being thrown.
Any help would be greatly appreciated.
The failing code sample is displayed below.< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
try
{
System.Xml.
XmlDocument xdoc = new System.Xml.XmlDocument();xdoc.LoadXml(
this.webBrowser.DocumentText);System.Xml.
XmlNodeList nl = xdoc.SelectNodes("/html/body/object"); foreach (System.Xml.XmlNode n in nl){
System.
Console.WriteLine(n.ToString()); XmlAttribute objWidth = n.Attributes["width"]; XmlAttribute objHeight = n.Attributes["height"]; if (objWidth != null){
objWidth.Value =
this.Width.ToString();}
if (objHeight != null){
objHeight.Value =
this.Height.ToString();}
}
this.webBrowser.DocumentText = xdoc.OuterXml;}
catch(System.Exception ex){System.
Console.WriteLine(ex.Message);}

Setting WebBrowser DocumentText fails silently sometimes.
Mattsa