Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more


get xml information using webbrowser control

Posted on 2002-05-10
Medium Priority
Last Modified: 2012-06-27
I am using a webbrowser control in vb6 and I want to get the xml information from it.  If I use view source on the web page I can see the xml information but when I put the html information into a text box the xml information is not there.
Question by:rjef
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +3
LVL 16

Expert Comment

ID: 7003864
How do you get source code?

' in document_complete event of webbrowser

debug.print webbrowser.document.documentelement.innerhtml

Author Comment

ID: 7003927
It doesn't give the same results as right click 'select all' then 'copy' then 'paste' into notepad. This is really what I want. It looks like it is giving the xml commands but not the data from the commands.
LVL 15

Expert Comment

ID: 7004766
There seems to be no way to use the Webbrowser control to get the underlying XML source.
You need to retrieve the original XML file.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 16

Expert Comment

ID: 7004777
"It doesn't give the same results as right click 'select all' then 'copy' then 'paste' into notepad.

Sorry, i don't understand, you did never talk about copy/paste stuff. Your primary question was:
".  If I use view
source on the web page I can see the xml information but when I put the html information into a text
box the xml information is not there. "
LVL 15

Expert Comment

ID: 7004786
XML in IE is converted to that syntax-highlighted HTML when displayed.

So it is:
LVL 16

Expert Comment

ID: 7004799
Well, what we need here, html code or pure text contents?
LVL 15

Expert Comment

ID: 7004818
pure text = xml

Author Comment

ID: 7005014
Ok lets stick with 'I need the same as view source'
The innertext does not give the same as view source.
The innerhtml does not give the same as view source
The selectall and copy does not give the same as view source

example innerhtml
<TD class=fm24 style="BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none" colSpan=3>Carrier</TD></TR></TBODY></TABLE></TD>
<TD class=fm26 style="BORDER-RIGHT: #999999 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #999999 1px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 0px; BORDER-BOTTOM: #999999 1px solid">
<TABLE class=fm26 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" cellSpacing=0 cellPadding=0 width="100%" border=0>

example innertext
19598783471203248663669PS80-02-F0778NULLNULLNULL5023-Apr-02 06:00 AM20-APR-2002YORK INTERNATIONAL S.A. DE C.VUPS NEXT DAYPA23-APR-2002
295989217112125776730104391-8-365..269NULLNULLNULL10006-May-02 08:00 PM26-APR-2002PARKER HANNIFIN CORPORATIONUPS GRNDOP06-MAY-2002

example viewsource
td class="fm31">663669</td><td class="fm32">PS80-02-F0778</td><td class="fm33">NULL</td><td class="fm34">NULL</td><td class="fm35">NULL</td><td class="fm36">50</td><td class="fm37">23-Apr-02 06:00 AM</td><td class="fm38">20-APR-2002</td><td class="fm39">YORK INTERNATIONAL S.A. DE C.V</td><td class="fm40">UPS NEXT DAY</td><td class="fm41">PA</td><td class="fm42">23-APR-2002</td></tr><tr><td class="row_number_cell">2</td><td class="fm29">959892171</td><td class="fm30">1212577</td><td class="fm31">673010</td><td class="fm32">4391-8-365..269</td><td class="fm33">NULL</td><td class="fm34">NULL</td><td class="fm35">NULL</td><td class="fm36">100</td><td class="fm37">06-May-02 08:00 PM</td><td class="fm38">26-APR-2002</td><td class="fm39">PARKER HANNIFIN CORPORATION</td><td class="fm40">UPS GRND</td><td class="fm41">OP</td><td class="fm42">06-MAY-2002</td></tr><tr><td class="row_number_cell">3</td><td

'selectall'  'copy'
1 959878347 1203248 663669 PS80-02-F0778 NULL NULL NULL 50 23-Apr-02 06:00 AM 20-APR-2002 YORK INTERNATIONAL S.A. DE C.V UPS NEXT DAY PA 23-APR-2002
2 959892171 1212577 673010 4391-8-365..269 NULL NULL NULL 100 06-May-02 08:00 PM 26-APR-2002 PARKER HANNIFIN CORPORATION UPS GRND OP 06-MAY-2002

If I could get the viewsource example the data I need is between the '>' '<'
LVL 15

Expert Comment

ID: 7007261
> <TD class=fm26 style="BORDER-RIGHT: #999999 1px solid;

Note: This doesn't look like XML at all, and it doesn't look like XML automatically converted to HTML by IE.

What is WebBrowser1.LocationURL?

Author Comment

ID: 7007516
It is an internal website
LVL 15

Expert Comment

ID: 7009490
What do you mean by,

>  I want to get the xml information from (an HTML document)

and what's the difference between an "internal" and an "external" website, regarding your question?
This is not a very clear question, try to make it clear or it's lost :-)

Author Comment

ID: 7010018
What I want to be able to get using the webbrowser control is the exact same information I get when I use the view>source option in the Internet Explorer.  I thought it was xml but I guess it is not.
The web site is internal to our company (behind a firewall)  I think it could also be called the intranet.

LVL 23

Accepted Solution

b1xml2 earned 800 total points
ID: 7039799
the problem rjef is this.

whenever you obtain a snapshot of the underlying data via the web browser control thru VB Code, you see the actual state of the DOM. This is not true with viewing the source via the Browser itself. Here the DOM may be re-arranged but you do not see the changes.

Under MSIE per se, all XML documents are transformed immediately with the defaultss.xsl.


Under the Browser Control's Document.body.innerHTML, you see the state of the DOM as it actually is and as such, you will see the transformed output. If you were to view it via the View Source Menu, you will see the XML document as it actually is.

If you want to view the XML, you should not be using the WebBrowser Control but the XMLHTTP object or DOMDocument30 | DOMDocument40 Object.

Sample Code
Set oHTTP = New Msxml2.XMLHTTP30 "GET","", False
Debug.Print oHTTP.responseXML.xml
LVL 49

Expert Comment

ID: 7722560
Hi rjef,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept b1xml2's comment(s) as an answer.

rjef, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
DanRollins -- EE database cleanup volunteer

Expert Comment

ID: 7780780
per recommendation

Community Support Moderator @Experts Exchange

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

647 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question