# HTML Parser

**URL:** <https://forum.xojo.com/t/html-parser/27506>\
**Category:** General\
**Created:** [October 23, 2015, 5:17pm UTC](https://forum.xojo.com/t/html-parser/27506 "2015-10-23T17:17:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonardo\_Capoccia1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@Leonardo\_Capoccia1](https://forum.xojo.com/u/Leonardo_Capoccia1)\
**Post date:** [October 23, 2015, 5:17pm UTC](https://forum.xojo.com/t/html-parser/27506/1 "2015-10-23T17:17:19Z")

</div>

Have anyone of you developed an HTML Parser?  
The thing that I need to do is to read an HTML page and extract some div with a fixed ID or Class.  
Anyone of you can tell me if there is some already made thing?  
Thanks to all

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [October 23, 2015, 5:46pm UTC](https://forum.xojo.com/t/html-parser/27506/2 "2015-10-23T17:46:18Z")

</div>

You could do this with a regular expression, something like:

```auto
<div .*id=\"put your id in here\".*>(.*)<\\/div>
```

the first match would be the contents of the div.

---

<div class="post-metadata">

**Author:** ![Axel\_Schneider](https://forum.xojo.com/user_avatar/forum.xojo.com/axel_schneider/32/465_2.png) [@Axel\_Schneider](https://forum.xojo.com/u/Axel_Schneider)\
**Post date:** [October 23, 2015, 5:51pm UTC](https://forum.xojo.com/t/html-parser/27506/3 "2015-10-23T17:51:19Z")

</div>

you can read the source text of the HTML Page

Document.Complete

```auto
me.ExecuteJavaScript "window.status = document.getElementsByTagName('html')[0].innerHTML;"
```

Status Changed

```auto
dim s as String = newStatus
s = NthField(s, "<div id="""xxxxx", 2)
s = NthField(s, "</div>", 1)
MSGBox s
```

---

<div class="post-metadata">

**Author:** ![Ashot\_Khachatryan](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@Ashot\_Khachatryan](https://forum.xojo.com/u/Ashot_Khachatryan)\
**Post date:** [October 23, 2015, 8:27pm UTC](https://forum.xojo.com/t/html-parser/27506/4 "2015-10-23T20:27:03Z")

</div>

Regex is the way to go, I scrape content from HTML that way all the time.

But remember to not overdo it [http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454)

🙂

---

<div class="post-metadata">

**Author:** ![Asis\_Patisahusiwa](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@Asis\_Patisahusiwa](https://forum.xojo.com/u/Asis_Patisahusiwa)\
**Post date:** [October 25, 2015, 12:23am UTC](https://forum.xojo.com/t/html-parser/27506/5 "2015-10-25T00:23:04Z")

</div>

I’ve developed HTML parser library using Xojo, similar to XMLDocument and has ability to extract contents of some tags using xpath. But, if you just analyze a html with same structure only, it’s more easy to use regex function.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:01pm UTC](https://forum.xojo.com/t/html-parser/27506/6 "2020-10-29T18:01:21Z")

</div>


