-1

我正在查看HTML:Element文档并遇到attr_get_i方法,根据文档指出:

在列表上下文中,返回一个列表,该列表由 $h 的给定属性的值及其从 $h 开始并向上工作的所有祖先的值组成。

现在,根据那里给出的例子:

<html lang='i-klingon'>
     <head><title>Pati Pata</title></head>
     <body>
       <h1 lang='la'>Stuff</h1>
       <p lang='es-MX' align='center'>
         Foo bar baz <cite>Quux</cite>.
       </p>
       <p>Hooboy.</p>
     </body>
   </html>

如果$h<cite> element$h->attr_get_i("lang")在列表上下文中将返回列表('es-MX', 'i-klingon')

现在,根据我的不理解,返回的列表应该('es-MX', 'la', 'i-klingon')是它也应该考虑<h1 lang='la'>Stuff</h1>但根据文档它没有。

现在,为什么我在这里错了。

4

2 回答 2

3

这里的“lang”属性是:

+-------------+------------------+
|    lang     |       path       |
+-------------+------------------+
| i-klingon   | /html            |
| la          | /html/body/h1    |
| es-MX       | /html/body/p     |
+-------------+------------------+

The <cite> node does not have <h1> as its parent (path is /html/body/p/cite), so <h1> is not its ancestor. This is why the method does not return it.

于 2012-09-12T17:26:18.807 回答
2

<h1 lang='la'>Stuff</h1>不是 的祖先 <cite>,是兄弟姐妹。

于 2012-09-12T17:25:03.933 回答