【问题标题】:how do i scan custom attributes from html tags?如何从 html 标签中扫描自定义属性?
【发布时间】:2013-02-13 01:05:51
【问题描述】:

如何从 html 标签中扫描自定义属性?
这是示例代码。
未确定的自定义属性名称。

<table>
    <tr>
        <td mycustom-attr1="true"></td>
        <td mycustom-attr2="true"></td>
        <td mycustom-attr3="false"></td>
    </tr>
</table>
<table>
    <tr>
        <td mycustom-attr1="true"></td>
        <td mycustom-attr2="true"></td>
        <td mycustom-attr3="false"></td>
    </tr>
</table>

我想从此 html 标记中提取到“mycustom-attr1、mycustom-attr2、mycustom-attr3”
搜索超过 1000 个 jsp 页面。

任何idia?

【问题讨论】:

  • 您使用哪种编程语言?
  • 你试过什么?当您提取确切的含义时,您需要对这些值做些什么?替换值?

标签: html regex xml tags


【解决方案1】:

您可以在大多数现代语言中使用 表达式来做到这一点。

举例:

/html/body/table[1]/tr/td/@*[starts-with(name(), 'mycustom')]

输出

 mycustom-attr1="true"
 mycustom-attr2="true"
 mycustom-attr3="false"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-07
    • 2014-01-14
    • 1970-01-01
    相关资源
    最近更新 更多