从字符串中剥离 HTML [英] Stripping HTML From A String

查看:40
本文介绍了从字符串中剥离 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了很多方法,但似乎没有任何工作正常.我有一个 Access DB,正在用 VBA 编写代码.我有一个 HTML 源代码字符串,我有兴趣从中剥离所有 HTML 代码和标签,这样我就只有纯文本字符串,没有剩下的 html 或标签.这样做的最佳方法是什么?

I've tried a number of things but nothing seems to be working properly. I have an Access DB and am writing code in VBA. I have a string of HTML source code that I am interested in stripping all of the HTML code and Tags out of so that I just have plain text string with no html or tags left. What is the best way to do this?

谢谢

推荐答案

一种对不良标记尽可能有弹性的方法;

One way that's as resilient as possible to bad markup;

with createobject("htmlfile")
    .open
    .write "<p>foo <i>bar</i> <u class='farp'>argle </zzzz> hello </p>"
    .close
    msgbox "text=" & .body.outerText
end with

这篇关于从字符串中剥离 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆