Unix and Linux Discussions Tagged with unix scripting basics |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
249 |
186,835 |
UNIX for Advanced & Expert Users |
|
|
|
409 |
348,082 |
Open Source |
|
|
|
192 |
203,587 |
Open Source |
|
|
|
182 |
159,389 |
SuSE |
|
|
|
1 |
3,590 |
Shell Programming and Scripting |
|
|
|
61 |
38,315 |
Web Development |
|
|
|
1 |
4,609 |
Shell Programming and Scripting |
|
|
|
54 |
31,552 |
What is on Your Mind? |
|
|
|
29 |
16,309 |
What is on Your Mind? |
|
|
|
11 |
30,899 |
Shell Programming and Scripting |
|
|
|
11 |
27,626 |
Shell Programming and Scripting |
|
|
|
13 |
140,135 |
Shell Programming and Scripting |
|
|
|
6 |
11,941 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
10,107 |
Shell Programming and Scripting |
|
|
|
15 |
46,284 |
Gentoo |
|
|
|
7 |
28,121 |
Shell Programming and Scripting |
|
|
|
3 |
53,995 |
Shell Programming and Scripting |
|
|
|
52 |
364,523 |
Shell Programming and Scripting |
|
|
|
11 |
13,281 |
UNIX for Dummies Questions & Answers |
|
|
|
8 |
7,743 |
Shell Programming and Scripting |
|
|
|
10 |
24,954 |
OS X (Apple) |
|
|
|
6 |
4,911 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
12,736 |
Windows & DOS: Issues & Discussions |
|
|
|
12 |
8,453 |
UNIX for Dummies Questions & Answers |
|
|
|
10 |
8,302 |
Shell Programming and Scripting |
|
|
|
4 |
30,549 |
UNIX Desktop Questions & Answers |
|
|
|
3 |
6,622 |
Programming |
|
|
|
4 |
32,688 |
Linux |
|
|
|
7 |
22,613 |
Shell Programming and Scripting |
|
|
|
4 |
14,643 |
Programming |
|
|
|
2 |
4,484 |
Shell Programming and Scripting |
|
|
|
3 |
12,974 |
Shell Programming and Scripting |
|
|
|
4 |
27,210 |
Shell Programming and Scripting |
|
|
|
3 |
8,553 |
Shell Programming and Scripting |
|
|
|
5 |
5,419 |
Shell Programming and Scripting |
|
|
|
2 |
2,537 |
Shell Programming and Scripting |
|
|
|
6 |
56,515 |
UNIX for Dummies Questions & Answers |
|
|
|
7 |
29,106 |
Solaris |
|
|
|
11 |
6,939 |
Shell Programming and Scripting |
|
|
|
1 |
23,499 |
Shell Programming and Scripting |
DOMDOCUMENT.GETELEMENTBYID(3) 1 DOMDOCUMENT.GETELEMENTBYID(3)
DOMDocument::getElementById - Searches for an element with a certain id
SYNOPSIS
public DOMElement DOMDocument::getElementById (string $elementId)
DESCRIPTION
This function is similar to "DOMDocument::getElementsByTagName" but searches for an element with a given id.
For this function to work, you will need either to set some ID attributes with "DOMElement::setIdAttribute" or a DTD which defines an
attribute to be of type ID. In the later case, you will need to validate your document with "DOMDocument::validate" or DOMDocument::$vali-
dateOnParse before using this function.
PARAMETERS
o $elementId
- The unique id value for an element.
RETURN VALUES
Returns the DOMElement or NULL if the element is not found.
EXAMPLES
Example #1
DOMDocument::getElementById() Example
The following examples use book.xml which contains the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE books [
<!ELEMENT books (book+)>
<!ELEMENT book (title, author+, xhtml:blurb?)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT blurb (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ATTLIST books xmlns CDATA #IMPLIED>
<!ATTLIST books xmlns:xhtml CDATA #IMPLIED>
<!ATTLIST book id ID #IMPLIED>
<!ATTLIST author email CDATA #IMPLIED>
]>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<books xmlns="http://books.php/" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<book id="php-basics">
<title>PHP Basics</title>
<author email="jim.smith@basics.php">Jim Smith</author>
<author email="jane.smith@basics.php">Jane Smith</author>
<xhtml:blurb><![CDATA[
<p><em>PHP Basics</em> provides an introduction to PHP.</p>
]]></xhtml:blurb>
</book>
<book id="php-advanced">
<title>PHP Advanced Programming</title>
<author email="jon.doe@advanced.php">Jon Doe</author>
</book>
</books>
<?php
$doc = new DomDocument;
// We need to validate our document before refering to the id
$doc->validateOnParse = true;
$doc->Load('book.xml');
echo "The element whose id is 'php-basics' is: " . $doc->getElementById('php-basics')->tagName . "
";
?>
The above example will output:
The element whose id is 'php-basics' is: book
SEE ALSO
DOMDocument::getElementsByTagName.
PHP Documentation Group DOMDOCUMENT.GETELEMENTBYID(3)