html - 如何通过 xlink :href attribute with CSS? 选择 XML 元素

标签 html css xml css-selectors xlink

有谁知道如何使用 CSS 通过 xlink:href 属性选择 XML 元素?

参见 here用法,但是它没有解释如何使用 CSS 选择它。

<book title="XQuery Kick Start">
  <description
    xlink:type="simple"
    xlink:href="http://book.com/images/XQuery.gif"
    xlink:show="new"> ... </description>
</book>

最佳答案

使用 CSS attribute selectors , 你需要 escape the colon : 前导反斜杠\,如下:

description[xlink\:href="http://book.com/images/HPotter.gif"] {
  background-color: gold;
}
<?xml version="1.0" encoding="UTF-8"?>

<bookstore xmlns:xlink="http://www.w3.org/1999/xlink">
  <book title="Harry Potter">
    <description
      xlink:type="simple"
      xlink:href="http://book.com/images/HPotter.gif"
      xlink:show="new"> ... </description>
  </book>

  <book title="XQuery Kick Start">
    <description
      xlink:type="simple"
      xlink:href="http://book.com/images/XQuery.gif"
      xlink:show="new"> ... </description>
  </book>
</bookstore>

WORKING DEMO .

关于html - 如何通过 xlink :href attribute with CSS? 选择 XML 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21950703/

相关文章:

php - 通过属性名称获取 XML 值

HTML Mail Outlook - 修复表格宽度,以便在不同屏幕上查看时不会被破坏

html - 调整图像大小以适合显示 :flex divs

css - 使用 css 对进入中心图形然后环绕中心图形进行动画处理

css - 向左浮动,流体布局

java - 使用 java 从 XML 文件中读取功能值

html - 元视口(viewport)问题

javascript - 检查 div 的边距而不是每隔一秒移动一次

javascript - 我怎样才能让我的导航栏在到达它时粘在元素的底部?

.net - 以编程方式从 XSD 创建 XML 文件