I am loading an xml document into a vb.net webbrowser object. I can not figure out how to get the xml out of it though. Basically I am going to a URL that has an xml document. It loads just fine - but now I need to write the xml to a file.
Here's my code:
-
Dim sXML As String
-
-
With WebBrowser1
-
.Navigate("http://www.redactive.com/wxc/Race1.xml")
-
Do Until .ReadyState = WebBrowserReadyState.Complete
-
Application.DoEvents()
-
Loop
-
If .DocumentType = "XML Document" Then
-
sXML = .Document.Body.OuterText
-
sXML = .Document.Body.InnerText
-
Else
-
MsgBox("Document is not XML", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information)
-
End If
-
-
-
End With
-
Notice that I try to assign OuterText and then InnerText to sXML. This was just so I could see what they contain. They contain the XML - but exactly what is displayed - including the silly little "-" or "+" to expand and contract the XML nodes - which makes the text basically malformed XML. I can remove these with sXML = sXML.Replace("-", " "), but that seems like it's not really the right thing to do. Since the DocumentType actually returns "XML Document" I assume there is a proper way to get XML out of the WebBrowser object. For the life of me though - I just can't find it!
By the way - you can run this code - the xml document for the test is at the specified URL.