get xml information using webbrowser control

Posted on 2002-05-10
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.
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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 200 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

730 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