Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get element from div class, no idea... 1

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
411
0
16
IT
Based this part of html...
<div id="dnn_ctr1675_Albo_dettagliPanel" class="dettagli-panel">
<div class="row">
<div id="dnn_ctr1675_Albo_geometraPanel" class="col-md-8">
<div class="panel panel-primary dettagli-panel__geometra-panel">
<div class="panel-heading">

<h3 id="dnn_ctr1675_Albo_dettagliPanelTitle" class="panel-title">Geometra regolarmente iscritto</h3>
</div>
<div class="panel-body clearfix">
<div class="row">
how to get the bold value?
 
To get the bold value, I would use regular expressions.
Are you using VBA in Excel ?
 
Yes vba.
But i need with DOM.
i use the tipical Ie object, in my vba Project.
 
I tried on following procedure:

1) Find a string that matches this regex pattern
Code:
<h3\s+.+h3>
which delivers this resulting string
Code:
<h3 id="dnn_ctr1675_Albo_dettagliPanelTitle" class="panel-title">Geometra regolarmente iscritto</h3>

2) From the previous intermediate resulting string remove h3-mark from the end using regex substitution with pattern
Code:
</h3>
which delivers this intermediate result
Code:
<h3 id="dnn_ctr1675_Albo_dettagliPanelTitle" class="panel-title">Geometra regolarmente iscritto

3) From the previous intermediate resulting string remove h3-mark from begin using regex substitution with pattern
Code:
<h3\s+.+>
which delivers the desired result
Code:
Geometra regolarmente iscritto

You can code similar procedure in VBA or VBscript orin any other suitable language which has support for regular expressions.
 
sal21 or 2009luca ? said:
But i need with DOM.
Then you can forget my previous answer with regex.

You will need to parse it as XML.

You will surely find some examples on Tek-Tips which get you start with parsing XML. In the past I have posted some examples myself on these forums
VBscript forum XML forum
Here is one example how to use XMLDOM in VBscript, in VBA it would be similar.
 
Sal21, I'd have thought you might have figured some of this out by now, given the various examples already provided. Still, here's another partial example ... assuming your document is in MyDoc, which is an HTMLDocument object, it's this simple:

Code:
    Set Example = myDoc.getElementById("dnn_ctr1675_Albo_dettagliPanelTitle")
MsgBox Example.innerText
 
Today I learned something new again
Thank strongm, it worked perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top