How to select XML element by xlink: href attribute using CSS?

Does anyone know how to select an XML element using an attribute xlink:hrefusing CSS?

See here for use, however it does not explain how to select it using CSS.

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

Using the CSS attribute selector , you need to output the colon : using a backslash \as follows:

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 .

+6
source

, XML, HTML, XML.

XML CSS, - xlink XLink spec, :

@namespace xlink 'http://www.w3.org/1999/xlink';

:

description[xlink|href="http://book.com/images/XQuery.gif"] {
    /* Styles */
}
+2

Think of it like regular html. Click the demo link below.

Demo

XML

<?xml version="1.0" encoding="UTF-8"?>

<homepages xmlns:xlink="http://www.w3.org/1999/xlink">

<homepage xlink:type="simple"
xlink:href="http://www.w3schools.com">Visit W3Schools</homepage>

<homepage xlink:type="simple"
xlink:href="http://www.w3.org">Visit W3C</homepage>

</homepages>

CSS

homepage{
    color:red;
}
0
source

All Articles