
Como puedo verificar si un elemento html es de tipo <h2>
Publicado por cesar (2 intervenciones) el 03/03/2022 17:49:43
Saludos...alguien sabe como puedo saber si un elemento html es de tipo <h2>?. Lo que quiero hacer es separar datos obtenidos de elementos <p> por medio de elementos <h2> del siguiente codigo html.
a traves de getElementsByClassName("contentBox") obtengo todos los elementos de la clase usando el siguiente codigo en vba. Cualquier ayuda es bienvenida, gracias de antemano
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<div class="contentBox">
<div class="pronounce-title"><h1>Acetylcysteine</h1><audio id="pronounce-audio" preload="none">
<source src="https://www.drugs.com/audio/mp3/97-0.mp3" type="audio/mpeg">
<source src="https://www.drugs.com/audio/wav/97-0.wav" type="audio/wav">
</audio>
<a id="pronunciation" class="pronounce-icon" href="#pronunciation" title="Listen to audio pronunciation" onclick="document.getElementById('pronounce-audio').play();return false;"><svg class="ddc-icon ddc-icon-pronunciation" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg"><path d="M10.73 3.81a1.75 1.75 0 013.02 1.2v13.97a1.75 1.75 0 01-3.02 1.2l-4.2-4.43H3.24v-7.5h3.27zm1.39.99a.25.25 0 00-.3.04l-4.07 4.3v5.72l4.07 4.3c.03.03.07.05.11.06l.07.01c.14 0 .25-.1.25-.25V5.02a.25.25 0 00-.08-.18zm5.7 1.52A6.24 6.24 0 0121.25 12a6.24 6.24 0 01-3.43 5.68.75.75 0 11-.64-1.36A4.74 4.74 0 0019.75 12c0-1.9-1.03-3.59-2.57-4.32a.75.75 0 11.64-1.36zm-1.48 3c.87.45 1.41 1.51 1.41 2.68 0 1.17-.54 2.23-1.41 2.67a.75.75 0 01-.76-1.29l.08-.05c.32-.16.59-.69.59-1.33 0-.59-.23-1.08-.5-1.28l-.09-.05a.75.75 0 11.68-1.34zm-10.09.43h-1.5v4.5h1.5v-4.5z"></path></svg></a></div>
<p class="drug-subtitle"><b>Generic name:</b> acetylcysteine (oral) (a SEET il SIS teen)<br><b>Brand name:</b> <i>NAC, N-A-C Sustain</i><br><b>Dosage forms:</b> oral capsule (500 mg; 600 mg); oral tablet (600 mg)<br><b>Drug class:</b> <a href="/drug-class/antidotes.html">Antidotes</a>, <a href="/drug-class/mucolytics.html">Mucolytics</a></p>
<p class="ddc-reviewed-by ddc-author-image-cerner" style="background-image: url(/img/logo/vendor/cerner-logomark.png);"><span><a href="/support/editorial_policy.html#editorial-staff">Medically reviewed</a> by Drugs.com on Dec 24, 2021. Written by <a href="/support/editorial_policy.html#cerner">Cerner Multum</a>.</span></p>
<nav class="ddc-anchor-links" aria-label="In page navigation" _mstaria-label="672347">
<div id="display-ad-injection-1" class="display-ad display-ad-injection display-ad-lazy display-ad-prebid display-ad-300 display-ad-300x250" data-google-query-id="CI-f3r2JqvYCFQi3lQIdLo4MOg"><div id="google_ads_iframe_/7146/drugs/mtm_1__container__" style="border: 0pt none;"><iframe id="google_ads_iframe_/7146/drugs/mtm_1" name="google_ads_iframe_/7146/drugs/mtm_1" title="3rd party ad content" width="300" height="250" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" role="region" aria-label="Advertisement" tabindex="0" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" srcdoc="" data-google-container-id="2" style="border: 0px; vertical-align: bottom;" data-load-complete="true"></iframe></div></div><ul>
<li><a href="#uses">Uses</a></li>
<li><a href="#warnings">Warnings</a></li>
<li><a href="#dosage">Dosage</a></li>
<li><a href="#what-to-avoid">What to avoid</a></li>
<li><a href="#side-effects">Side effects</a></li>
<li><a href="#interactions">Interactions</a></li>
</ul>
</nav>
<div id="WhatIs"></div>
<h2 id="uses" class="ddc-anchor-offset">What is acetylcysteine?</h2>
<p>Acetylcysteine is used to help prevent or lessen liver damage caused by taking large quantities of <a href="/acetaminophen.html" data-type="auto">acetaminophen</a> (<a href="/tylenol.html" data-type="auto">Tylenol</a>).</p>
<p>There are other brands and forms of acetylcysteine available, and some can be purchased over the counter. Not all forms of acetylcysteine are effective as an acetaminophen antidote. Do not attempt to treat an <a href="/cg/acetaminophen-overdose.html" data-type="auto">acetaminophen overdose</a> without medical advice.</p>
<p>Acetylcysteine may also be used for purposes not listed in this medication guide.</p>
<div id="Important"></div>
<h2 id="warnings" class="ddc-anchor-offset">Warnings</h2>
<p>In an emergency, you may not be able to tell caregivers about your health conditions. Make sure any doctor caring for you afterward knows you received this medicine.</p>
<div id="NotTake"></div>
<h2>Before taking this medicine</h2>
a traves de getElementsByClassName("contentBox") obtengo todos los elementos de la clase usando el siguiente codigo en vba. Cualquier ayuda es bienvenida, gracias de antemano
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Dim XMLPage As New MSXML2.XMLHTTP60
Dim htmldoc As New MSHTML.HTMLDocument
Dim htmlims As MSHTML.IHTMLElementCollection
categoria = "/mtm/Acetylcysteine.html"
URL = "https://www.drugs.com" & categoria
XMLPage.Open "Get", URL, False
XMLPage.setRequestHeader "Content-Type", "text/xml"
XMLPage.send
On Error Resume Next
htmldoc.body.innerHTML = XMLPage.responseText
Set htmlims = htmldoc.getElementsByClassName("contentBox")
Valora esta pregunta


0