Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extract div block from HTML using xPath or QM string functions
#2
Can use HtmlDoc class

Function Function35
Code:
Copy      Help
str html=
;<!DOCTYPE html>
;<html>
;;;;<head>
;;;;;;;;<title>Page Title</title>
;;;;</head>
;;;;<body>
;;;;;;;;<div class="title">
;;;;;;;;;;;;<a href="https://www.download/book.pdf" target="_blank">
;;;;;;;;;;;;;;;;Book title
;;;;;;;;;;;;</a>
;;;;;;;;;;;;<div class="js-subproduct-admin-edit" data-entity-kind="subproduct" data-machine-name="booktitle_1"></div>
;;;;;;;;</div>
;;;;;;;;</div class="some_other_block">
;;;;;;;;;;;;test
;;;;;;;;</div>
;;;;</body>
;</html>

HtmlDoc d.InitFromText(html)
ARRAY(MSHTML.IHTMLElement) div
int i
d.GetHtmlElements(div "div")
for i 0 div.len
,str cn=div[i].className
,if cn="title"
,,out "------------------InnerHtml------------------"
,,out div[i].innerHTML
,,out "------------------OuterHtml------------------"
,,out div[i].outerHTML


Messages In This Thread
RE: Extract div block from HTML using xPath or QM string functions - by Kevin - 03-02-2022, 05:23 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)