Mervin
Mervin

Reputation: 113

How to get XML-code of webpage that is opened in IE (without using WebRequest)?

I'm trying to get an XML-text from a wabpage, that is already opened in IE. Web requests are not allowed because of a security of target page (long boring story with certificates etc). I use method to walk through all opened pages and, if I found a match with page's URI, I need to get it's XML. Some time ago I needed to get an HTML-code between body tags. I used method with IHTMLDocument2 like this:

private string GetSourceHTML()
{            
    Regex reg = new Regex(patternURL);
    Match match;
    string result;
    foreach (SHDocVw.InternetExplorer ie in shellWindows)
    { 
        match = reg.Match(ie.LocationURL.ToString());
        if (!string.IsNullOrEmpty(match.Value))
        {
            mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)ie.Document;
            result = doc.body.innerHTML.ToString();
            return result;
        }                
    }
    result = string.Empty;
    return result;            
}

So now I need to get a whole XML-code of a target page. I've googled a lot, but didn't find anything useful. Any ideas? Thanks.

Upvotes: 0

Views: 593

Answers (1)

UnitStack
UnitStack

Reputation: 1185

Have you tried this? It should get the HTML, which hopefully you could parse to XML?

Upvotes: 1

Related Questions