Unix and Linux Discussions Tagged with unix scripting basics |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
409 |
422,872 |
Open Source |
|
|
|
192 |
260,128 |
Open Source |
|
|
|
249 |
261,940 |
UNIX for Advanced & Expert Users |
|
|
|
182 |
206,367 |
SuSE |
|
|
|
1 |
4,983 |
Shell Programming and Scripting |
|
|
|
61 |
48,712 |
Web Development |
|
|
|
1 |
5,331 |
Shell Programming and Scripting |
|
|
|
54 |
42,493 |
What is on Your Mind? |
|
|
|
29 |
20,555 |
What is on Your Mind? |
|
|
|
11 |
32,676 |
Shell Programming and Scripting |
|
|
|
11 |
29,005 |
Shell Programming and Scripting |
|
|
|
13 |
141,911 |
Shell Programming and Scripting |
|
|
|
6 |
12,825 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
11,333 |
Shell Programming and Scripting |
|
|
|
15 |
54,290 |
Gentoo |
|
|
|
7 |
29,969 |
Shell Programming and Scripting |
|
|
|
3 |
55,042 |
Shell Programming and Scripting |
|
|
|
52 |
374,714 |
Shell Programming and Scripting |
|
|
|
11 |
14,575 |
UNIX for Dummies Questions & Answers |
|
|
|
8 |
8,965 |
Shell Programming and Scripting |
|
|
|
10 |
28,323 |
OS X (Apple) |
|
|
|
6 |
5,862 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
14,629 |
Windows & DOS: Issues & Discussions |
|
|
|
12 |
10,103 |
UNIX for Dummies Questions & Answers |
|
|
|
10 |
9,838 |
Shell Programming and Scripting |
|
|
|
4 |
32,507 |
UNIX Desktop Questions & Answers |
|
|
|
3 |
7,272 |
Programming |
|
|
|
4 |
33,520 |
Linux |
|
|
|
7 |
23,532 |
Shell Programming and Scripting |
|
|
|
4 |
15,417 |
Programming |
|
|
|
2 |
5,129 |
Shell Programming and Scripting |
|
|
|
3 |
13,403 |
Shell Programming and Scripting |
|
|
|
4 |
28,047 |
Shell Programming and Scripting |
|
|
|
3 |
9,405 |
Shell Programming and Scripting |
|
|
|
5 |
6,158 |
Shell Programming and Scripting |
|
|
|
2 |
2,987 |
Shell Programming and Scripting |
|
|
|
6 |
58,437 |
UNIX for Dummies Questions & Answers |
|
|
|
7 |
30,162 |
Solaris |
|
|
|
11 |
8,058 |
Shell Programming and Scripting |
|
|
|
1 |
23,879 |
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)