mirror of
https://github.com/php/doc-en.git
synced 2026-03-24 07:42:10 +01:00
* Document DOMNode::DOCUMENT_POSITION_* class constants * Document DOMNode::compareDocumentPosition() * Update reference/dom/domnode/compareDocumentPosition.xml Co-authored-by: Gina Peter Banyard <girgias@php.net> --------- Co-authored-by: Gina Peter Banyard <girgias@php.net>
97 lines
2.4 KiB
XML
97 lines
2.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<refentry xml:id="domnode.comparedocumentposition" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>DOMNode::compareDocumentPosition</refname>
|
|
<refpurpose>Compares the position of two nodes</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis role="DOMNode">
|
|
<modifier>public</modifier> <type>int</type><methodname>DOMNode::compareDocumentPosition</methodname>
|
|
<methodparam><type>DOMNode</type><parameter>other</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
Compares the position of the other node relative to this node.
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>other</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The node for which the position should be compared for, relative to this node.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<simpara>
|
|
A bitmask of the <constant>DOMNode::DOCUMENT_POSITION_<replaceable>*</replaceable></constant>
|
|
constants.
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title><methodname>DOMNode::compareDocumentPosition</methodname> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$xml = <<<XML
|
|
<root>
|
|
<child1/>
|
|
<child2/>
|
|
</root>
|
|
XML;
|
|
|
|
$dom = new DOMDocument();
|
|
$dom->loadXML($xml);
|
|
|
|
$root = $dom->documentElement;
|
|
$child1 = $root->firstElementChild;
|
|
$child2 = $child1->nextElementSibling;
|
|
|
|
var_dump($root->compareDocumentPosition($child1));
|
|
var_dump($child2->compareDocumentPosition($child1));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
int(20) // This is DOMNode::DOCUMENT_POSITION_CONTAINED_BY | DOMNode::DOCUMENT_POSITION_FOLLOWING
|
|
int(2) // This is DOMNode::DOCUMENT_POSITION_PRECEDING
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</refsect1>
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|