|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<refentry xml:id="domnode.comparedocumentposition" xmlns="http://docbook.org/ns/docbook"> |
| 3 | + <refnamediv> |
| 4 | + <refname>DOMNode::compareDocumentPosition</refname> |
| 5 | + <refpurpose>Compares the position of two nodes</refpurpose> |
| 6 | + </refnamediv> |
| 7 | + |
| 8 | + <refsect1 role="description"> |
| 9 | + &reftitle.description; |
| 10 | + <methodsynopsis role="DOMNode"> |
| 11 | + <modifier>public</modifier> <type>int</type><methodname>DOMNode::compareDocumentPosition</methodname> |
| 12 | + <methodparam><type>DOMNode</type><parameter>other</parameter></methodparam> |
| 13 | + </methodsynopsis> |
| 14 | + <simpara> |
| 15 | + Compares the position of the other node relative to this node. |
| 16 | + </simpara> |
| 17 | + </refsect1> |
| 18 | + |
| 19 | + <refsect1 role="parameters"> |
| 20 | + &reftitle.parameters; |
| 21 | + <variablelist> |
| 22 | + <varlistentry> |
| 23 | + <term><parameter>other</parameter></term> |
| 24 | + <listitem> |
| 25 | + <para> |
| 26 | + The node for which the position should be compared for, relative to this node. |
| 27 | + </para> |
| 28 | + </listitem> |
| 29 | + </varlistentry> |
| 30 | + </variablelist> |
| 31 | + </refsect1> |
| 32 | + |
| 33 | + <refsect1 role="returnvalues"> |
| 34 | + &reftitle.returnvalues; |
| 35 | + <simpara> |
| 36 | + A bitmask of the <link linkend="domnode.constants">DOMNode::DOCUMENT_POSITION_*</link> |
| 37 | + constants. |
| 38 | + </simpara> |
| 39 | + </refsect1> |
| 40 | + |
| 41 | + <refsect1 role="examples"> |
| 42 | + &reftitle.examples; |
| 43 | + <example> |
| 44 | + <title><methodname>DOMNode::compareDocumentPosition</methodname> example</title> |
| 45 | + <programlisting role="php"> |
| 46 | +<![CDATA[ |
| 47 | +<?php |
| 48 | +$xml = <<<XML |
| 49 | +<root> |
| 50 | + <child1/> |
| 51 | + <child2/> |
| 52 | +</root> |
| 53 | +XML; |
| 54 | +
|
| 55 | +$dom = new DOMDocument(); |
| 56 | +$dom->loadXML($xml); |
| 57 | +
|
| 58 | +$root = $dom->documentElement; |
| 59 | +$child1 = $root->firstElementChild; |
| 60 | +$child2 = $child1->nextElementSibling; |
| 61 | +
|
| 62 | +var_dump($root->compareDocumentPosition($child1)); |
| 63 | +var_dump($child2->compareDocumentPosition($child1)); |
| 64 | +?> |
| 65 | +]]> |
| 66 | + </programlisting> |
| 67 | + &example.outputs; |
| 68 | + <screen> |
| 69 | +<![CDATA[ |
| 70 | +int(20) // This is DOMNode::DOCUMENT_POSITION_CONTAINED_BY | DOMNode::DOCUMENT_POSITION_FOLLOWING |
| 71 | +int(2) // This is DOMNode::DOCUMENT_POSITION_PRECEDING |
| 72 | +]]> |
| 73 | + </screen> |
| 74 | + </example> |
| 75 | + </refsect1> |
| 76 | +</refentry> |
| 77 | +<!-- Keep this comment at the end of the file |
| 78 | +Local variables: |
| 79 | +mode: sgml |
| 80 | +sgml-omittag:t |
| 81 | +sgml-shorttag:t |
| 82 | +sgml-minimize-attributes:nil |
| 83 | +sgml-always-quote-attributes:t |
| 84 | +sgml-indent-step:1 |
| 85 | +sgml-indent-data:t |
| 86 | +indent-tabs-mode:nil |
| 87 | +sgml-parent-document:nil |
| 88 | +sgml-default-dtd-file:"~/.phpdoc/manual.ced" |
| 89 | +sgml-exposed-tags:nil |
| 90 | +sgml-local-catalogs:nil |
| 91 | +sgml-local-ecat-files:nil |
| 92 | +End: |
| 93 | +vim600: syn=xml fen fdm=syntax fdl=2 si |
| 94 | +vim: et tw=78 syn=sgml |
| 95 | +vi: ts=1 sw=1 |
| 96 | +--> |
0 commit comments