在属性简单的HTML DOM通配符 [英] Simple HTML DOM wildcard in attribute

查看:209
本文介绍了在属性简单的HTML DOM通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码

<div class="col *">Text</div>

* 是什么。

我想获得的所有div标签类属性包含山坳(在我的例子)使用的简单的HTML DOM

I want to get all div tag with class attribute contains col (as in my example) using Simple HTML DOM.

推荐答案

由于简单的HTML DOM 确实已经有选择含有一定的价值和属性的方法|或别的东西。例如:

Since Simple HTML DOM does already have a method for selecting attributes that contain a certain value and|or something else. For example

$ HTML的&GT;找到(DIV [*类COL =],0) - &GT; outertext

或者你可以只检索与山坳开始像这样 DIV 节点

Or you could just retrieve div nodes that start with col like so

$ HTML的&GT;找到(DIV [^类= COL],0) - &GT; outertext

和进行安全保管,你可以找到所有的其他的方式来过滤这个第三方插件属性(顺便说一句有处理DOM的方式更好的东西,是基于的libxml ,最终列表可<一个href=\"http://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-with-php/3577662#3577662\">found这里)

And for safe keeping you can find all the other ways to filter attributes in this 3rd party plugin (By the way there are way better things for dealing with DOM that are based on libxml, a definitive list can be found here)


  1. [属性] - 匹配具有特定属性的元素

  2. [属性!] - 匹配不具有指定属性的元素

  3. [属性=值] - 匹配有具有一定值的指定属性的元素

  4. [属性=值!] - 匹配没有具有一定值的指定属性的元素

  5. [^属性值=] - 匹配具有指定属性的元素,它具有一定的值开始

  6. [属性$ =值] - 匹配具有指定属性的元素,它具有一定的值结束

  7. [属性* =值] - 匹配具有指定属性的元素,并含有一定值

  1. [attribute] - Matches elements that have the specified attribute.
  2. [!attribute] - Matches elements that don't have the specified attribute.
  3. [attribute=value] - Matches elements that have the specified attribute with a certain value.
  4. [attribute!=value] - Matches elements that don't have the specified attribute with a certain value.
  5. [attribute^=value] - Matches elements that have the specified attribute and it starts with a certain value.
  6. [attribute$=value] - Matches elements that have the specified attribute and it ends with a certain value.
  7. [attribute*=value] - Matches elements that have the specified attribute and it contains a certain value.

来源:<一个href=\"http://simplehtmldom.sourceforge.net/manual.htm\">http://simplehtmldom.sourceforge.net/manual.htm

这篇关于在属性简单的HTML DOM通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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